Redis Append command
Redis Append command to append the value of the specified key.
If the key already exists and is a string, APPEND command value is appended to the end of the key original value.
If the key does not exist, APPEND is simply set to a given key value, the same as the implementation of SET key value.
grammar
redis Append command basic syntax is as follows:
redis 127.0.0.1:6379> APPEND KEY_NAME NEW_VALUE
Available versions
> = 2.0.0
return value
After the additional value is specified, the length of the key in the string.
Examples
# 对不存在的 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"