增加
命令 |
解释 |
SET key value |
设置指定 key 的值 |
MGET key1 [key2..] |
获取所有(一个或多个)给定 key 的值 |
MSETNX key value [key value …] |
同时设置一个或多个 key-value 对,当且仅当所有给定 key 都不存在 |
SETNX key value |
只有在 key 不存在时设置 key 的值 |
删除
命令 |
解释 |
FLUSHDB |
清空当前数据库 |
FLUSHALL |
清空所有数据库 |
查询
命令 |
解释 |
KEY * |
查询所有key |
GET key |
获取指定 key 的值 |
GETRANGE key start end |
返回 key 中字符串值的子字符 |
GETSET key value |
将给定 key 的值设为 value ,并返回 key 的旧值(old value) |
STRLEN key |
返回 key 所储存的字符串值的长度 |
修改
命令 |
解释 |
SETEX key seconds value |
将值 value 关联到 key ,并将 key 的过期时间设为 seconds (以秒为单位)。 |
PSETEX key milliseconds value |
这个命令和 SETEX 命令相似,但它以毫秒为单位设置 key 的生存时间,而不是像 SETEX 命令那样,以秒为单位 |
SETRANGE key offset value |
从偏移量开始赋值 |
INCR key |
将 key 中储存的数字值增一 |
INCRBY key increment |
将 key 所储存的值加上给定的增量值(increment) |
INCRBYFLOAT key increment |
将 key 所储存的值加上给定的浮点增量值(increment) |
DECR key |
将 key 中储存的数字值减一 |
DECRBY key decrement |
key 所储存的值减去给定的减量值(decrement) |
APPEND key value |
如果 key 已经存在并且是一个字符串, APPEND 命令将指定的 value 追加到该 key 原来值(value)的末尾 |
其他
http://www.redis.cn/commands.html#string
help @string
APPEND key value
summary: Append a value to a key
since: 2.0.0
BITCOUNT key [start end]
summary: Count set bits in a string
since: 2.6.0
BITFIELD key [GET type offset] [SET type offset value] [INCRBY type offset increment] [OVERFLOW WRAP|SAT|FAIL]
summary: Perform arbitrary bitfield integer operations on strings
since: 3.2.0
BITOP operation destkey key [key ...]
summary: Perform bitwise operations between strings
since: 2.6.0
BITPOS key bit [start] [end]
summary: Find first bit set or clear in a string
since: 2.8.7
DECR key
summary: Decrement the integer value of a key by one
since: 1.0.0
DECRBY key decrement
summary: Decrement the integer value of a key by the given number
since: 1.0.0
GET key
summary: Get the value of a key
since: 1.0.0
GETBIT key offset
summary: Returns the bit value at offset in the string value stored at key
since: 2.2.0
GETRANGE key start end
summary: Get a substring of the string stored at a key
since: 2.4.0
GETSET key value
summary: Set the string value of a key and return its old value
since: 1.0.0
INCR key
summary: Increment the integer value of a key by one
since: 1.0.0
INCRBY key increment
summary: Increment the integer value of a key by the given amount
since: 1.0.0
INCRBYFLOAT key increment
summary: Increment the float value of a key by the given amount
since: 2.6.0
MGET key [key ...]
summary: Get the values of all the given keys
since: 1.0.0
MSET key value [key value ...]
summary: Set multiple keys to multiple values
since: 1.0.1
MSETNX key value [key value ...]
summary: Set multiple keys to multiple values, only if none of the keys exist
since: 1.0.1
PSETEX key milliseconds value
summary: Set the value and expiration in milliseconds of a key
since: 2.6.0
SET key value [EX seconds] [PX milliseconds] [NX|XX]
summary: Set the string value of a key
since: 1.0.0
SETBIT key offset value
summary: Sets or clears the bit at offset in the string value stored at key
since: 2.2.0
SETEX key seconds value
summary: Set the value and expiration of a key
since: 2.0.0
SETNX key value
summary: Set the value of a key, only if the key does not exist
since: 1.0.0
SETRANGE key offset value
summary: Overwrite part of a string at key starting at the specified offset
since: 2.2.0
STRLEN key
summary: Get the length of the value stored in a key
since: 2.2.0