📅  最后修改于: 2020-11-26 07:02:10             🧑  作者: Mango
Redis字符串命令用于管理Redis中的字符串值。以下是使用Redis字符串命令的语法。
redis 127.0.0.1:6379> COMMAND KEY_NAME
redis 127.0.0.1:6379> SET tutorialspoint redis
OK
redis 127.0.0.1:6379> GET tutorialspoint
"redis"
在上面的示例中, SET和GET是命令,而tutorialspoint是关键。
下表列出了一些在Redis中管理字符串的基本命令。
Sr.No | Command & Description |
---|---|
1 | SET key value
This command sets the value at the specified key. |
2 | GET key
Gets the value of a key. |
3 | GETRANGE key start end
Gets a substring of the string stored at a key. |
4 | GETSET key value
Sets the string value of a key and return its old value. |
5 | GETBIT key offset
Returns the bit value at the offset in the string value stored at the key. |
6 | MGET key1 [key2..]
Gets the values of all the given keys |
7 | SETBIT key offset value
Sets or clears the bit at the offset in the string value stored at the key |
8 | SETEX key seconds value
Sets the value with the expiry of a key |
9 | SETNX key value
Sets the value of a key, only if the key does not exist |
10 | SETRANGE key offset value
Overwrites the part of a string at the key starting at the specified offset |
11 | STRLEN key
Gets the length of the value stored in a key |
12 | MSET key value [key value …]
Sets multiple keys to multiple values |
13 | MSETNX key value [key value …]
Sets multiple keys to multiple values, only if none of the keys exist |
14 | PSETEX key milliseconds value
Sets the value and expiration in milliseconds of a key |
15 | INCR key
Increments the integer value of a key by one |
16 | INCRBY key increment
Increments the integer value of a key by the given amount |
17 | INCRBYFLOAT key increment
Increments the float value of a key by the given amount |
18 | DECR key
Decrements the integer value of a key by one |
19 | DECRBY key decrement
Decrements the integer value of a key by the given number |
20 | APPEND key value
Appends a value to a key |