BLMPOP
BLMPOP timeout numkeys key [key ...] LEFT | RIGHT [COUNT count]
- Group
- List
- Complexity
- O(N+M) where N is the number of keys checked and M is the number of elements returned
- Arity
- -5 (at least 5 words, counting the command name)
- Flags
- write, blocking
- HotKV Cloud
- All plans
- On-Premise
- no license needed
BLMPOP is the blocking form of LMPOP. It checks the keys
in order and pops up to count elements (default 1) from the head (LEFT)
or tail (RIGHT) of the first non-empty list. If every list is empty or
missing, the connection waits until one of the keys receives elements or
timeout passes, then pops from that key.
timeout is in seconds, can have a fractional part, and 0 waits forever.
Inside MULTI / EXEC and inside scripts,
BLMPOP never waits and replies at once as if the timeout had expired.
Options
Section titled “Options”| Option | Effect |
|---|---|
timeout |
Seconds to wait; 0 waits forever. |
numkeys |
How many keys follow. Must be greater than 0. |
LEFT / RIGHT |
Pop from the head or the tail. |
COUNT count |
Pop up to count elements. Must be greater than 0. |
The arguments after timeout are checked before timeout itself.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Popped | Two-element array: the key, then an array of the popped elements | Same |
| Timeout expired | Nil array | Null |
Errors:
ERR numkeys should be greater than 0,ERR count should be greater than 0, orERR syntax error, as for LMPOP.ERR timeout is not a float or out of range,ERR timeout is negative, orERR timeout is out of rangefor a badtimeout.WRONGTYPEif a key reached before the first non-empty list holds a value that is not a list.
Examples
Section titled “Examples”127.0.0.1:6379> RPUSH q:low l1 l2 l3(integer) 3127.0.0.1:6379> BLMPOP 5 2 q:high q:low RIGHT COUNT 21) "q:low"2) 1) "l3" 2) "l2"127.0.0.1:6379> BLMPOP 0.2 1 q:high LEFT(nil)(0.20s)Compatibility
Section titled “Compatibility”Same as Redis 7.4 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.