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

Redis Blpop Command

Redis Blpop Command

Redis List

The Redis Blpop command removes and returns the first 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 Blpop command is as follows:



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

Available Version

= 2.0.0

Return Value

If the list is empty, returns nil. 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 127.0.0.1:6379> BLPOP list1 100

In the example above, the operation will block; if the specified list key list1 has data, it returns the first element, otherwise it returns nil after waiting 100 seconds.



(nil)

(100.06s)

Redis List