Redis Brpoplpush Command
The Redis Brpoplpush command pops the last element from a list and pushes it to the head of another list; if the list has no elements, it blocks until a timeout is reached or an element becomes available to pop.
Syntax
The basic syntax of the redis Brpoplpush command is as follows:
redis 127.0.0.1:6379> BRPOPLPUSH LIST1 ANOTHER_LIST TIMEOUT
Available Version
= 2.0.0
Return Value
If no element is popped within the specified time, returns nil and the waiting duration. Otherwise, returns a two-element list where 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" # 弹出元素的值
(3.38s) # 等待时长
redis> LLEN reciver
(integer) 1
redis> LRANGE reciver 0 0
1) "hello moto"
# 空列表
redis> BRPOPLPUSH msg reciver 1
(nil)
(1.34s)
Redis List