English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The commands related to the Redis string data type are used to manage Redis string values, and the basic syntax is as follows:
redis 127.0.0.1:6379> COMMAND KEY_NAME
redis 127.0.0.1:6379> SET w3codeboxkey redis OK redis 127.0.0.1:6379> GET w3codeboxkey "redis"
In the above examples, we used SET and GET Command, key is w3codeboxkey.
The following table lists commonly used redis string commands:
Serial number | Command and description |
---|---|
1 | SET key value Set the value of the specified key |
2 | GET key Get the value of the specified key. |
3 | GETRANGE key start end Return the substring of the string value in the key. |
4 | GETSET key value Set the value of the given key to value and return the old value of the key. |
5 | GETBIT key offset Get the bit at the specified offset of the string value stored at the key. |
6 | MGET key1 [key2..] Get all (one or more) values of the given key. |
7 | SETBIT key offset value Set or clear the bit at the specified offset of the string value stored at the key. |
8 | SETEX key seconds value Associate the value value with the key and set the expiration time of the key to seconds (in seconds). |
9 | SETNX key value Set the value of the key only if the key does not exist. |
10 | SETRANGE key offset value Use the value parameter to overwrite the string value stored at the given key, starting from the offset offset. |
11 | STRLEN key Return the length of the string value stored at key. |
12 | Set the value of the key to the specified value. Set one or more keys at the same time-value if the value is set. |
13 | MSETNX key value [key value ...] Set one or more keys at the same time-value if all given keys do not exist. |
14 | PSETEX key milliseconds value This command is similar to the SETEX command, but it sets the expiration time of the key in milliseconds instead of seconds as the SETEX command does. |
15 | INCR key Increase the numeric value stored at key by one. |
16 | INCRBY key increment Increase the value stored at key by the given increment. |
17 | INCRBYFLOAT key increment Increase the value stored at key by the given floating-point increment. |
18 | DECR key Decrease the numeric value stored at key by one. |
19 | DECRBY key decrement Decrease the value stored at key by the given decrement. |
20 | APPEND key value If the key already exists and it is a string, the APPEND command will append the specified value to the end of the original value (value) of the key. |
For more commands, please refer to:https://redis.io/commands