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:

Resp3

One of the following:

Complexity

O(N) where N is the number of elements returned

Acl Categories

@fast @list @write

History

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)

Info

2024-09-23 8.0.0 Valkey Command Manual