Redis Append Command
The Redis Append command is used to append a value to the specified key.
If the key already exists and is a string, the APPEND command appends the value to the end of the original value of the key.
If the key does not exist, APPEND simply sets the given key to the value, similar to executing SET key value.
Syntax
The basic syntax of the redis Append command is as follows:
redis 127.0.0.1:6379> APPEND KEY_NAME NEW_VALUE
Available Versions
= 2.0.0
Return Value
The length of the string in the key after appending the specified value.
Examples
# APPEND to a non-existing key
redis> EXISTS myphone # Ensure myphone does not exist
(integer) 0
redis> APPEND myphone "nokia" # APPEND to a non-existing key, equivalent to SET myphone "nokia"
(integer) 5 # Character length
# APPEND to an existing string
redis> APPEND myphone " - 1110" # Length increases from 5 to 12 characters
(integer) 12
redis> GET myphone
"nokia - 1110"