Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Brpop Command

Redis Brpop Command

Redis List

The Redis Brpop command removes and returns the last element of the list; if the list has no elements, it blocks the list until a timeout is reached or an element becomes available to pop.

Syntax

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



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

Available Version

= 2.0.0

Return Value

If no element is popped within the specified time, returns nil and the waiting duration. Otherwise, returns a two-element list where the first element is the key of the popped element and the second element is the value of the popped element.

Example



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