brpop.3valkey - Man Page

Removes and returns the last element in a list. Blocks until an element is available otherwise. Deletes the list if the last element was popped.

Synopsis

BRPOP key [key...] timeout

Description

BRPOP is a blocking list pop primitive. It is the blocking version of RPOP because it blocks the connection when there are no elements to pop from any of the given lists. An element is popped from the tail of the first list that is non-empty, with the given keys being checked in the order that they are given.

See the BLPOP documentation for the exact semantics, since BRPOP is identical to BLPOP with the only difference being that it pops elements from the tail of a list instead of popping from the head.

Reply

Resp2

One of the following:

  • valkey-protocol(7) Nil reply: no element could be popped and the timeout expired.
  • valkey-protocol(7) Array reply: the key from which the element was popped and the value of the popped element

Resp3

One of the following:

  • valkey-protocol(7) Null reply: no element could be popped and the timeout expired.
  • valkey-protocol(7) Array reply: the key from which the element was popped and the value of the popped element

Complexity

O(N) where N is the number of provided keys.

Acl Categories

@blocking @list @slow @write

History

Examples

127.0.0.1:6379> DEL list1 list2
(integer) 0
127.0.0.1:6379> RPUSH list1 a b c
(integer) 3
127.0.0.1:6379> BRPOP list1 list2 0
1) "list1"
2) "c"

See Also

blmove(3valkey), blmpop(3valkey), blpop(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), rpop(3valkey), rpush(3valkey), rpushx(3valkey)

Info

2024-09-23 8.0.0 Valkey Command Manual