UK[əˈpend] US[əˈpɛnd]

vt.Attach; add; paste; sign (name)

Third person singular: appends Present participle: appending Past tense: appended past Participle: appended

redis APPEND command syntax

Function: If key already exists and is a string, the APPEND command will append value to the end of the original value of key. If key does not exist, APPEND simply sets the given key to value, just like executing SET key value .

Syntax: APPEND key value

Available versions:>= 2.0.0

Time complexity : Amortized O(1)

Return: The length of the string in key after appending value.

redis APPEND command example

# 对不存在的 key 执行 APPEND
redis> EXISTS myphone               # 确保 myphone 不存在
(integer) 0
redis> APPEND myphone "nokia"       # 对不存在的 key 进行 APPEND ,等同于 SET myphone "nokia"
(integer) 5                         # 字符长度
# 对已存在的字符串进行 APPEND
redis> APPEND myphone " - 1110"     # 长度从 5 个字符增加到 12 个字符
(integer) 12
redis> GET myphone
"nokia - 1110"