LMPOP
LMPOP 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
- -4 (at least 4 words, counting the command name)
- Flags
- write
- HotKV Cloud
- All plans
- On-Premise
- no license needed
LMPOP checks the given keys in order and pops from the first one that holds
a non-empty list. It pops from the head (LEFT) or the tail (RIGHT), up to
count elements (default 1), all from that one list. The list is deleted
when it becomes empty.
To wait when every list is empty, use BLMPOP.
Options
Section titled “Options”| Option | Effect |
|---|---|
numkeys |
How many keys follow. Must be greater than 0. |
LEFT |
Pop from the head. |
RIGHT |
Pop from the tail. |
COUNT count |
Pop up to count elements. Must be greater than 0. Can be given once. |
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Popped | Two-element array: the key, then an array of the popped elements | Same |
| All keys missing or empty | Nil array | Null |
Errors:
ERR numkeys should be greater than 0ifnumkeysis not a positive integer.ERR syntax errorif fewer keys follow thannumkeyssays, the direction is missing or notLEFT/RIGHT, orCOUNTis repeated or unknown words follow.ERR count should be greater than 0ifcountis not a positive integer.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:high h1(integer) 1127.0.0.1:6379> RPUSH q:low l1 l2 l3(integer) 3127.0.0.1:6379> LMPOP 2 q:high q:low LEFT COUNT 21) "q:high"2) 1) "h1"127.0.0.1:6379> LMPOP 2 q:high q:low LEFT COUNT 21) "q:low"2) 1) "l1" 2) "l2"127.0.0.1:6379> LMPOP 1 nosuchkey RIGHT(nil)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.