LMPOP numkeys key LEFT | RIGHT [COUNT]
Available since
Time complexity
O(N+M) where N is the number of provided keys and M is the number of elements returned.
ACL categories
@write, @list, @slow

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).

Examples #

LMPOP 2 non1 non2 LEFT COUNT 10
LPUSH mylist "one" "two" "three" "four" "five"
LMPOP 1 mylist LEFT
LRANGE mylist 0 -1
LPUSH mylist "one" "two" "three" "four" "five"
LPUSH mylist2 "a" "b" "c" "d" "e"
LMPOP 2 mylist mylist2 right count 3
LRANGE mylist 0 -1
LMPOP 2 mylist mylist2 right count 5
LMPOP 2 mylist mylist2 right count 10
EXISTS mylist mylist2

Redict logo courtesy of @janWilejan, CC-BY-SA-4.0. Download SVG ⤑

Portions of this website courtesy of Salvatore Sanfilippo, CC-BY-SA-4.0.