Redis async API using MULTI

27 views
Skip to first unread message

Naveen Kak

unread,
Jan 19, 2022, 10:41:40 AMJan 19
to Redis DB

While using a async hiredis client, is it guaranteed that all the async api’s invoked from the client will be executed in a  sequential order on the redis server? 

I thought since connection to Redis server is over TCP, so everything should be delivered to server in order.

I see some articles where they have raised this reservation for using MULTI for async APIs.

 

Snippet from below link:

===================

It is impossible to use MULTI-EXEC over Redis Asynchronous API. You can only choose one.

MULTI-EXEC transactions SHOULD always execute sequentially. Redis Asynchronous API, on the other hand, allows the commands to be delivered out of order. Hence, it won't make sense to make a MULTI-EXEC transaction if the commands aren't in the proper sequence or worse, if MULTI and EXEC commands themselves became out of order.

 

https://stackoverflow.com/questions/16431802/redis-how-to-use-async-multi

Viktor Söderqvist

unread,
Jan 24, 2022, 5:58:42 AMJan 24
to redi...@googlegroups.com
Hi Naveen,

Async commands are executed in order. TCP is ordered, as you say,
and it is possible to send multiple commands without waiting for
a response. This is called pipelining. MULTI-EXEC with pipelining
is a good idea. It is efficient. From
https://redis.io/topics/transactions

> (...) starting with Redis 2.6.5, the server will remember that
> there was an error during the accumulation of commands, and
> will refuse to execute the transaction returning also an error
> during EXEC, and discarding the transaction automatically.
>
> Before Redis 2.6.5 the behavior was to execute the transaction
> with just the subset of commands queued successfully in case
> the client called EXEC regardless of previous errors. The new
> behavior makes it much more simple to mix transactions with
> pipelining, so that the whole transaction can be sent at once,
> reading all the replies later at once.

There is no mention of out-of-order commands in the hiredis
README or in the Redis documentation. The information you found
seems wrong or at least very outdated.

Br,
Viktor
> https://stackoverflow.com/questions/16431802/redis-how-to-use-async-multi <https://stackoverflow.com/questions/16431802/redis-how-to-use-async-multi>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Redis DB" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to redis-db+u...@googlegroups.com
> <mailto:redis-db+u...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/redis-db/2f143435-a54e-4e3c-abd8-80918a396e87n%40googlegroups.com
> <https://groups.google.com/d/msgid/redis-db/2f143435-a54e-4e3c-abd8-80918a396e87n%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages