rpop.3valkey - Man Page
Returns and removes the last elements of a list. Deletes the list if the last element was popped.
Synopsis
RPOP
key [count]
Description
Removes and returns the last elements of the list stored at key
.
By default, the command pops a single element from the end 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.
Reply
Resp2
One of the following:
- valkey-protocol(7) Nil reply: if the key does not exist.
- valkey-protocol(7) Bulk string reply: when called without the count argument, the value of the last element.
- valkey-protocol(7) Array reply: when called with the count argument, a list of popped elements.
Resp3
One of the following:
- valkey-protocol(7) Null reply: if the key does not exist.
- valkey-protocol(7) Bulk string reply: when called without the count argument, the value of the last element.
- valkey-protocol(7) Array reply: when called with the count argument, a list of popped elements.
Complexity
O(N) where N is the number of elements returned
Acl Categories
@fast @list @write
History
- Available since: 1.0.0
- Changed in 6.2.0: Added the
count
argument.
Examples
127.0.0.1:6379> RPUSH mylist "one" "two" "three" "four" "five" (integer) 5 127.0.0.1:6379> RPOP mylist "five" 127.0.0.1:6379> RPOP mylist 2 1) "four" 2) "three" 127.0.0.1:6379> LRANGE mylist 0 -1 1) "one" 2) "two"
See Also
blmove(3valkey), blmpop(3valkey), blpop(3valkey), brpop(3valkey), lindex(3valkey), linsert(3valkey), llen(3valkey), lmove(3valkey), lmpop(3valkey), lpop(3valkey), lpos(3valkey), lpush(3valkey), lpushx(3valkey), lrange(3valkey), lrem(3valkey), lset(3valkey), ltrim(3valkey), rpush(3valkey), rpushx(3valkey)