Redis APPEND – How to append a string to an existing string value in redis

2 months ago Lalit Bhagtani 0

In this tutorial, we will learn about how to append a string to an existing string value stored at the key in redis datastore. For this, we will use a Redis APPEND command.

APPEND Command

This command appends a specified string to an existing string value stored at the key. If the key doesn’t exist in redis datastore, it is first created and set to empty string before performing the append operation. Error is returned, if the key exists but value stored at the key is not a string. The syntax of Redis APPEND command is as follows :-

Syntax :-

redis host:post> APPEND <key name>

Output :- 

(integer) value, representing the number of characters in the string.
Error, if key exist and value stored at the key is not a string.

Example :-

Redis APPEND

References :-

  1. APPEND Command Docs

That’s all for how to append a string to a existing string value stored in redis datastore. If you liked it, please share your thoughts in comments section and share it with others too.

<- String Commands