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 執(zhí)行 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"