redis BRPOPLPUSH command


  Translation results:

pop

UK[pɒp] US[pɑ:p]

vi. (unexpectedly, suddenly) appear; appear suddenly; make a popping sound; (suddenly) action

vt. (suddenly) reach out; (suddenly) ask a question; (suddenly take out something prepared); strike

n.pop music ; soda; (especially used as a title) dad; (quickly marked)

adj. pop music; popular style; popular; modern

adv. explosion; bang

abbr.post office protocol

Third person singular: pops Plural: pops Present participle: popping Past tense: popped Past participle: popped

push

UK[pʊʃ] US[pʊʃ]

vt.& vi. Push, push

vt. Press; push, increase; exert pressure on... , force; persuade

n. push, determination; large-scale offensive; determined pursuit

vi. advance; increase; strive for

Third person singular: pushes present participle : pushing past tense: pushed past participle: pushed

redis BRPOPLPUSH commandsyntax

Function: BRPOPLPUSH is the blocking version of RPOPLPUSH. When the given list source is not empty, BRPOPLPUSH behaves the same as RPOPLPUSH.

Syntax: BRPOPLPUSH source destination timeout

Description: When the list source is empty, the BRPOPLPUSH command will block the connection until the wait times out, or Until another client executes the LPUSH or RPUSH command on the source. The timeout parameter timeout accepts a number in seconds as a value. Setting the timeout parameter to 0 means that the blocking time can be extended indefinitely (block indefinitely).

Available versions: >= 2.2.0

Time complexity: O(1)

Return: If no element is popped out within the specified time, return a nil and the waiting time. Otherwise, a list containing two elements is returned. The first element is the value of the popped element, and the second element is the waiting time.

redis BRPOPLPUSH commandexample

# 非空列表
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)

Home

Videos

Q&A