Redis Brpoplpush Command
The Redis Brpoplpush command pops the last element from a list and inserts it into the head of another list; if the list has no elements, it blocks the list until the wait times out or a popable element is found.
Syntax
The basic syntax of 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 time. Otherwise, it returns a list containing two elements: the first element is the value of the popped element, and the second element is the waiting time.
Examples
# 非空列表 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)Other Extensions
Redis List