English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Redis Append Command

Redis Strings (string)

The Redis APPEND command is used to append values to specified keys.

If the key already exists and is a string, the APPEND command will append value to the end of the original value of key.

If the key does not exist, APPEND simply sets the given key to value, just like 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.

Online 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 from 5 characters increased to 12 characters
(integer) 12
redis> GET myphone
"nokia - 1110"

Redis Strings (string)