redis RPUSH 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 RPUSH commandsyntax
Function:One or more values value is inserted into the end (rightmost) of the list key.
Syntax: RPUSH key value [value ...]
Description: If there are multiple value values, then each value value is based on Insert to the end of the table in order from left to right: For example, if you execute RPUSH mylist a b c on an empty list mylist, the resulting list is a b c, which is equivalent to executing the commands RPUSH mylist a, RPUSH mylist b, RPUSH mylist c. If key does not exist, an empty list will be created and the RPUSH operation performed. When key exists but is not a list type, an error is returned. RPUSH commands before Redis 2.4 only accept a single value value.
Available versions: >= 1.0.0
Time complexity: O(1)
Return: The length of the table after executing the RPUSH operation.
redis RPUSH commandexample
# 添加单个元素 redis> RPUSH languages c (integer) 1 # 添加重复元素 redis> RPUSH languages c (integer) 2 redis> LRANGE languages 0 -1 # 列表允许重复元素 1) "c" 2) "c" # 添加多个元素 redis> RPUSH mylist a b c (integer) 3 redis> LRANGE mylist 0 -1 1) "a" 2) "b" 3) "c"