Redis Brpop Command

Redis List (List)

The Redis Brpop command removes and gets the last element of a list. If the list has no elements, it will block the list until a timeout is reached or a popable element is found.

Syntax

The basic syntax of the redis Brpop command is as follows:

redis 127.0.0.1:6379> BRPOP LIST1 LIST2 .. LISTN TIMEOUT 

Available Versions

>= 2.0.0

Return Value

If no element is popped within the specified time, a nil and the waiting duration are returned. Conversely, a list containing two elements is returned: the first element is the key to which the popped element belongs, and the second element is the value of the popped element.

Examples

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

Redis List (List)

Other Extensions