📜  Redis字符串

📅  最后修改于: 2020-12-02 01:03:46             🧑  作者: Mango

Redis字符串

Redis字符串命令用于管理Redis中的字符串值。请参阅使用Redis字符串命令的语法。

句法:

redis 127.0.0.1:6379> COMMAND KEY_NAME 

redis 127.0.0.1:6379> SET javatpoint redis 
OK 
redis 127.0.0.1:6379> GET javatpoint 
"redis"

在这里,SET和GET是命令,“ javatpoint”是关键。

Redis字符串命令

以下是一些用于在Redis中管理字符串的基本命令的列表。

Index Command Description
1 SET key value This command is used to set the value at the specified key.
2 GET key This command is used to retrieve the value of a key.
3 GETRANGE key start end This command is used to get a substring of the string stored at a key.
4 GETSET key value This command is used to set the string value of a key and return its old value.
5 GETBIT key offset This command is used to return the bit value at the offset in the string value stored at the key.
6 MGET key1 [key2..] This command is used to get the values of all the given keys
7 SETBIT key offset value This command is used to set or clear the bit at the offset in the string value stored at the key
8 SETEX key seconds value This command is used to set the value with the expiry of a key
9 SETNX key value This command is used to set the value of a key, only if the key does not exist
10 SETRANGE key offset value This command is used to overwrite the part of a string at the key starting at the specified offset
11 STRLEN key This command is used to retrieve the length of the value stored in a key
12 MSET key value [key value …] This command is used to set multiple keys to multiple values
13 MSETNX key value [key value …] This command is used to set multiple keys to multiple values, only if none of the keys exist
14 PSETEX key milliseconds value This command is used to set the value and expiration in milliseconds of a key
15 INCR key This command is used to increment the integer value of a key by one
16 INCRBY key increment This command is used to increment the integer value of a key by the given amount
17 INCRBYFLOAT key increment This command is used to increment the float value of a key by the given amount
18 DECR key This command is used to decrement the integer value of a key by one
19 DECRBY key decrement This command is used to decrement the integer value of a key by the given number
20 APPEND key value This command is used to append a value to a key