Suppose there are two clients which are accessing same redis list datastructure. One is doing LPOP and other is doing RPUSH on the same list. Will there be a any contention between these two clients if they are running in parallel ? Will Redis lock mylist (below) when one client is accessing it,even if the clients running in parallel are accessing different ends of mylist?
Client 1
RPUSH mylist a
RPUSH mylist b
Client 2
LPOP mylist
LPOP mylist
Client 1 and Client 2 are running in parallel. Let me know if there will be contention in such a scenario.
Redis is single-threaded, so every command that comes to it is (guaranteed to be) executed atomically. There is no parallel/concurrent access to redis' data structures, so in your scenario you cannot tell who's gonna execute first.
one won't block the other, unless you use MULTI/EXEC to create a transaction, to avoid race conditions where one client POPS before the other client finishes to PUSH N values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With