English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Redis Brpop Command

Redis Lists (List)

The Redis Brpop command removes and retrieves the last element of the list, if the list has no elements it will block the list until the timeout or a removable 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 Version

>= 2.0.0

Return Value

If no elements are popped within the specified time, it returns a nil and the waiting time. In the opposite case, it returns a list containing two elements, the first element is the key of the popped element, and the second element is the value of the popped element.

Online 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 Lists (List)