Can multiple clients get the same list at the same time without blocking in Redis?

Suppose there are two clients that access the same redis list data structure. One does LPOP and the other does RPUSH on the same list. Will there be a conflict between these two clients if they work in parallel? Will Redis block mylist (below) when one client accesses it, even if clients running in parallel access to different ends of the list?

Client 1 RPUSH mylist a RPUSH mylist b Client 2 LPOP mylist LPOP mylist 

Client 1 and Client 2 work in parallel. Let me know if there will be a conflict in such a scenario.

+4
source share
2 answers

Redis is single-threaded, so every command that comes to it (executed) is executed atomically. There is no parallel / parallel access to redis data structures, so in your scenario you cannot tell who will execute the first.

+6
source

one will not block the other unless you use MULTI / EXEC to create a transaction to avoid race conditions when one client POPS before the other client completes the PUSH N.

0
source

Source: https://habr.com/ru/post/1398957/


All Articles