Redis String (String)

Commands related to the Redis string data type are used to manage redis string values. The basic syntax is as follows:

grammar

redis 127.0.0.1:6379> COMMAND KEY_NAME

example

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

In the above example we used the SET and GET commands with the key runoobkey .

Redis String Commands

The following table lists commonly used redis string commands:

serial number Command and Description
1 SET key value
sets the value of the specified key
2 GET key
Gets the value of the specified key.
3 GETRANGE key start end
returns the subcharacter of the string value in key
4 GETSET key value
sets the value of the given key to value and returns the old value of the key.
5 GETBIT key offset
Gets the bit at the specified offset for the string value stored in key.
6 MGET key1 [key2..]
Gets all (one or more) values ​​for the given key.
7 SETBIT key offset value
Sets or clears the bit at the specified offset for the string value stored at key.
8 SETEX key seconds value
Associates the value value to key and sets the key's expiration time to seconds (in seconds).
9 SETNX key value
sets the value of the key only if the key does not exist.
10 SETRANGE key offset value Overwrites
the string value stored at the given key with the value parameter, starting at offset offset.
11 STRLEN key
returns the length of the string value stored at key.
12 MSET key value [key value ...]
Sets one or more key-value pairs at the same time.
13 MSETNX key value [key value ...]
simultaneously sets one or more key-value pairs if and only if none of the given keys exist.
14 PSETEX key milliseconds value
This command is similar to the SETEX command, but it sets the key's lifetime in milliseconds instead of seconds like the SETEX command.
15 INCR key
increments the numeric value stored in the key by one.
16 INCRBY key increment
adds the value stored at key to the given increment.
17 INCRBYFLOAT key increment
adds the value stored at key to the given floating point increment value (increment).
18 The DECR key
decrements the numeric value stored in the key by one.
19 DECRBY key decrement
key 所储存的值减去给定的减量值(decrement) 。
20 APPEND key value
如果 key 已经存在并且是一个字符串, APPEND 命令将 指定value 追加到改 key 原来的值(value)的末尾。

 

更多命令请参考:https://redis.io/commands

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325086915&siteId=291194637