The Redis string command is used to manage string values in Redis. The syntax for using the Redis String command is as follows:
Grammar
Redis 127.0.0.1:6379> COMMAND Key_name
Example
Redis 127.0.0.1:6379> SET Yiibai Redis
Ok
Redis 127.0.0.1:6379> GET Yiibai
"Redis"
In the example above, set and get are commands, and Yiibai is the key.
Redis string command
The following table shows some of the basic commands in the Redis management string:
| S.N. |
Command & Description |
| 1 |
SET Key value
This command is used to set the value in the specified key. |
| 2 |
GET Key
The value that corresponds to the key. |
| 3 |
GETRANGE Key Start end
Gets the substring of the string stored in a key |
| 4 |
Getset Key value
Sets the string value of the key and returns the old value. |
| 5 |
Getbit Key Offset
Returns the offset of a string value stored in a keyed value |
| 6 |
MGET Key1 [Key2 ...]
Get all the values of the given key |
| 7 |
Setbit Key Offset value
Sets or clears the string value offset for the bit stored in the key |
| 8 |
Setex Key seconds value
Set value when key expires |
| 9 |
Setnx Key value
Sets the value of the key only if the key does not exist |
| 10 |
SETRANGE Key Offset value
Overrides the offset of a part of a string from a specified key |
| 11 |
STRLEN Key
Gets the length of the value stored in the key |
| 12 |
MSET key value [key value ...]
Set multiple keys and multiple values |
| 13 |
Msetnx key value [key value ...]
Set multiple keys Multiple values, only when there is no presence of the key |
| 14 |
Psetex Key milliseconds value
Set the millisecond value and expiration time of the key |
| 15 |
INCR Key
Increase the integer value of the key one time |
| 16 |
Incrby Key Increment
An integer value that increments the key by the given number |
| 17 |
Incrbyfloat Key Increment
A floating-point value that increments the key by a given number |
| 18 |
DECR key
An integer value that decrements the key once |
| 19 |
Decrby Key Decrement
An integer value that decrements the key by a given number |
| 20 |
APPEND Key value
Append value to a key |
Redis QuickStart-Redis strings (8)