Redis – Strings
Redis strings commands are used for managing string values in Redis. Following is the syntax for using Redis string commands.
Syntax
redis 127.0.0.1:6379> COMMAND KEY_NAME
Example
redis 127.0.0.1:6379> SET tutorialspoint redis OK redis 127.0.0.1:6379> GET tutorialspoint "redis"
In the above example, SET and GET are the commands, while tutorialspoint is the key.
Redis Strings Commands
Following table lists some basic commands to manage strings in Redis.
Sr.No | Command & Description |
---|---|
1 |
This command sets the value at the specified key. |
2 |
Gets the value of a key. |
3 |
Gets a substring of the string stored at a key. |
4 |
Sets the string value of a key and return its old value. |
5 |
Returns the bit value at the offset in the string value stored at the key. |
6 |
Gets the values of all the given keys |
7 |
Sets or clears the bit at the offset in the string value stored at the key |
8 |
Sets the value with the expiry of a key |
9 |
Sets the value of a key, only if the key does not exist |
10 |
Overwrites the part of a string at the key starting at the specified offset |
11 |
Gets the length of the value stored in a key |
12 |
Sets multiple keys to multiple values |
13 |
Sets multiple keys to multiple values, only if none of the keys exist |
14 |
Sets the value and expiration in milliseconds of a key |
15 |
Increments the integer value of a key by one |
16 |
Increments the integer value of a key by the given amount |
17 |
Increments the float value of a key by the given amount |
18 |
Decrements the integer value of a key by one |
19 |
Decrements the integer value of a key by the given number |
20 |
Appends a value to a key |