LPOP

Syntax
LPOP key [count]
Available since:
1.0.0
Time complexity:
O(N) where N is the number of elements returned
ACL categories:
@write, @list, @fast,

Removes and returns the first elements of the list stored at key.

By default, the command pops a single element from the beginning of the list. When provided with the optional count argument, the reply will consist of up to count elements, depending on the list's length.

Examples

RPUSH mylist "one" "two" "three" "four" "five" LPOP mylist LPOP mylist 2 LRANGE mylist 0 -1

RESP2 Reply

One of the following:

  • Nil reply: if the key does not exist.
  • Bulk string reply: when called without the count argument, the value of the first element.
  • Array reply: when called with the count argument, a list of popped elements.

RESP3 Reply

One of the following:

  • Null reply: if the key does not exist.
  • Bulk string reply: when called without the count argument, the value of the first element.
  • Array reply: when called with the count argument, a list of popped elements.

History

  • Starting with Redis version 6.2.0: Added the count argument.
Rate this page