-
Notifications
You must be signed in to change notification settings - Fork 292
Description
Page https://redis.io/docs/latest/commands/blpop
In the documentation of BLPOP, it says the following
When a client is blocking for multiple keys at the same time, and elements are available at the same time in multiple keys (because of a transaction or a Lua script added elements to multiple lists), the client will be unblocked using the first key that received a push operation (assuming it has enough elements to serve our client, as there may be other clients as well waiting for this key). Basically after the execution of every command Redis will run a list of all the keys that received data AND that have at least a client blocked. The list is ordered by new element arrival time, from the first key that received data to the last. For every key processed, Redis will serve all the clients waiting for that key in a FIFO fashion, as long as there are elements in this key. When the key is empty or there are no longer clients waiting for this key, the next key that received new data in the previous command / transaction / script is processed, and so forth.
But when I ran these 2 redis client on a docker container:
Client A: BLPOP key1 key2 0
Client B:
MULTI
RPUSH key2 1 2 3 4
RPUSH key1 5 6 7
EXEC
I get the result:
1) "key1"
2) "5"
But according to the documentation since key2 receives the data first, it should be the one unblocking Client A and the result should be:
1) "key2"
2) "1"
Am I missing some detail on how the BLPOP works, or is the documentation outdated? In either case, the doc seems to be a little misleading