LMPOP numkeys [key [key ...]] LEFT|RIGHT [COUNT count]

Pops one or more elements from the first non-empty list key from the list of provided key names.

LMPOP and BLMPOP are similar to the following, more limited, commands: - LPOP or RPOP which take only one key, and can return multiple elements. - BLPOP or BRPOP which take multiple keys, but return only one element from just one key.

See BLMPOP for the blocking variant of this command.

Elements are popped from either the left or right of the first non-empty list based on the passed argument. The number of returned elements is limited to the lower between the non-empty list's length, and the count argument (which defaults to 1).

*Return value

Array reply: specifically:

  • A nil when no element could be popped.
  • A two-element array with the first element being the name of the key from which elements were popped, and the second element is an array of elements.

*Examples

redis>  LMPOP 2 non1 non2 LEFT COUNT 10
ERR Don't know what to do for "lmpop"
redis>  LPUSH mylist "one" "two" "three" "four" "five"
(integer) 5
redis>  LMPOP 1 mylist LEFT
ERR Don't know what to do for "lmpop"
redis>  LRANGE mylist 0 -1
1) "five"
2) "four"
3) "three"
4) "two"
5) "one"
redis>  LMPOP 1 mylist RIGHT COUNT 10
ERR Don't know what to do for "lmpop"
redis>  LPUSH mylist "one" "two" "three" "four" "five"
(integer) 10
redis>  LPUSH mylist2 "a" "b" "c" "d" "e"
(integer) 5
redis>  LMPOP 2 mylist mylist2 right count 3
ERR Don't know what to do for "lmpop"
redis>  LRANGE mylist 0 -1
1) "five"
 2) "four"
 3) "three"
 4) "two"
 5) "one"
 6) "five"
 7) "four"
 8) "three"
 9) "two"
10) "one"
redis>  LMPOP 2 mylist mylist2 right count 5
ERR Don't know what to do for "lmpop"
redis>  LMPOP 2 mylist mylist2 right count 10
ERR Don't know what to do for "lmpop"
redis>  EXISTS mylist mylist2
(integer) 2
redis>