Easy Tutorial
❮ Connection Ping Sets Sinter ❯

Redis Brpoplpush Command

Redis Lists

The Redis Brpoplpush command removes the last element from a list and inserts it at the head of another list. If the list is empty, it blocks the list until a timeout occurs or a poppable element is found.

Syntax

The basic syntax for the redis Brpoplpush command is as follows:

redis 127.0.0.1:6379> BRPOPLPUSH LIST1 ANOTHER_LIST TIMEOUT

Available Versions

= 2.0.0

Return Value

If no element is popped within the specified time, it returns a nil and the waiting duration. Otherwise, it returns a list with two elements: the first element is the value of the popped element, and the second element is the waiting duration.

Example

# Non-empty list

redis> BRPOPLPUSH msg reciver 500
"hello moto"                        # Value of the popped element
(3.38s)                             # Waiting duration

redis> LLEN reciver
(integer) 1

redis> LRANGE reciver 0 0
1) "hello moto"


# Empty list

redis> BRPOPLPUSH msg reciver 1
(nil)
(1.34s)

Redis Lists

❮ Connection Ping Sets Sinter ❯