Redis Blpop Command

Redis List

Redis Blpop command removes and gets the first element of the list. If the list has no elements, it will block the list until the wait times out or a poppable element is found.

Syntax

The basic syntax of the Redis Blpop command is as follows:

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

Available versions

>= 2.0.0

Return value

If the list is empty, a nil is returned. Otherwise, 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.

Example

redis 127.0.0.1:6379> BLPOP list1 100

In the above example, the operation will be blocked. If the specified list key list1 has data, it will return the first element; otherwise, it will return nil after waiting 100 seconds.

(nil)
(100.06s)

Redis List

Other extensions