redis RPUSHX command
Translation results:
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. push; increase; strive for
Third person singular: pushes Present participle: pushing Past tense: pushed Past participle: pushed
redis RPUSHX commandsyntax
Function: Insert value value into the end of list key if and only if key exists and is a list.
Syntax: RPUSHX key value
Explanation: Contrary to the RPUSH command, when the key does not exist, the RPUSHX command does nothing.
Available versions: >= 2.2.0
Time complexity: O(1)
Return: RPUSHX The length of the table after the command is executed.
redis RPUSHX commandexample
# key不存在 redis> LLEN greet (integer) 0 redis> RPUSHX greet "hello" # 对不存在的 key 进行 RPUSHX,PUSH 失败。 (integer) 0 # key 存在且是一个非空列表 redis> RPUSH greet "hi" # 先用 RPUSH 插入一个元素 (integer) 1 redis> RPUSHX greet "hello" # greet 现在是一个列表类型,RPUSHX 操作成功。 (integer) 2 redis> LRANGE greet 0 -1 1) "hi" 2) "hello"