LMPOP

Since 1.1.0Lists

Syntax

LMPOP numkeys key [key ...] LEFT|RIGHT [COUNT count]
  • Flags: movablekeys, write
  • ACL categories: @list, @slow, @write
  • Arity: -4

Pops elements from the first of the given lists that is not empty. numkeys is how many keys follow.

Options

OptionEffect
LEFT, RIGHTPop from the head or the tail.
COUNT countPop up to count elements (1 by default).

Reply

  • A two-element array: the key popped from, and the elements.
  • nil if every list is empty.

Examples

> RPUSH q2 x y z
(integer) 3
> LMPOP 2 q1 q2 LEFT
1) "q2"
2) 1) "x"
> LMPOP 2 q1 q2 RIGHT COUNT 5
1) "q2"
2) 1) "z"
   2) "y"