BRPOP

Syntax
BRPOP key [key ...] timeout
Available since:
2.0.0
Time complexity:
O(N) where N is the number of provided keys.
ACL categories:
@write, @list, @slow, @blocking,

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.

Examples

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

RESP2 Reply

One of the following:

  • Nil reply: no element could be popped and the timeout expired.
  • Array reply: the key from which the element was popped and the value of the popped element

RESP3 Reply

One of the following:

  • Null reply: no element could be popped and the timeout expired.
  • Array reply: the key from which the element was popped and the value of the popped element

History

  • Starting with Redis version 6.0.0: timeout is interpreted as a double instead of an integer.
Rate this page