w3resource

Redis Lists: BRPOPLPUSH

BRPOPLPUSH source destination timeout

Redis BRPOPLPUSH command is used to block the connection until another client pushes to it or until a timeout is reached when source is empty. When source contains element then this command Atomically returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at the destination.

Syntax:

redis 127.0.0.1:6379> BRPOPLPUSH LIST1 ANOTHER_LIST TIMEOUT    

Available since

2.2.0.

Return Value

String reply, value of element stored at key or nil

Return Value Type

String

Example: Redis BRPOPLPUSH

127.0.0.1:6379> RPUSH mycolor1 R G B
(integer) 3
127.0.0.1:6379> RPUSH mycolor2 Y O P
(integer) 3
127.0.0.1:6379> BRPOPLPUSH  mycolor1 mycolor2 100
"B"
127.0.0.1:6379> BRPOPLPUSH  mycolor1 mycolor2 100
"G"
127.0.0.1:6379> BRPOPLPUSH  mycolor1 mycolor2 100
"R"
127.0.0.1:6379> BRPOPLPUSH  mycolor1 mycolor2 100

(nil)
(100.06s)

Above example will block the client for 100 seconds to execute any command. If any data comes in the specified key lists then it will pop data and push it into another list otherwise after 100 seconds nil value is returned.

(nil)
(100.06s)

Previous: BRPOP
Next: LINDEX



Follow us on Facebook and Twitter for latest update.