Redis 作为 KV型数据库的”一哥“,在诸多互联网大厂中得到广泛的应用,同时这也对开发者提出更高的要求,那么你知道redis都有哪些命令吗?

redis命令分类

利用redis-cli中的help命令,可以很好的帮助我们了解以及学习redis都有哪些命令;

127.0.0.1:6379> help
redis-cli 6.0.9
To get help about Redis commands type:
      "help @<group>" to get a list of commands in <group>
      "help <command>" for help on <command>
      "help <tab>" to get a list of possible help topics
      "quit" to exit
命令分类描述
help @generic通用类key的相关操作
help @string字符串字符串的相关操作
help @list列表list的相关操作
help @set集合set的相关操作
help @sorted_set有序集合有序set的相关操作
help @hashhash字典hash字典的相关操作
help @pubsub发布订阅发布订阅的相关操作
help @transactions事务事务的相关操作
help @connection连接连接的相关操作
help @server服务端server的相关操作
help @scripting脚本脚本的相关操作
help @hyperlogloghyperlogloghyperloglog的相关操作
help @cluster集群集群的相关操作
help @geo地理位置地理位置的相关操作
help @streamstream的相关操作

Redis 作为 KV型数据库的”一哥“,在诸多互联网大厂中得到广泛的应用,同时这也对开发者提出更高的要求,那么你知道redis都有哪些命令吗?

redis命令分类

help 命令

利用redis-cli中的help命令,可以很好的帮助我们了解以及学习redis都有哪些命令;

127.0.0.1:6379> help
redis-cli 6.0.9
To get help about Redis commands type:
      "help @<group>" to get a list of commands in <group>
      "help <command>" for help on <command>
      "help <tab>" to get a list of possible help topics
      "quit" to exit

命令分类

命令分类描述
help @generic通用类key的相关操作
help @string字符串字符串的相关操作
help @list列表list的相关操作
help @setset集合set的相关操作
help @sorted_set有序set集合有序set的相关操作
help @hash字典hash字典的相关操作
help @pubsub发布订阅发布订阅的相关操作
help @transactions事务事务的相关操作
help @connection连接连接的相关操作
help @server服务端server的相关操作
help @scripting脚本脚本的相关操作
help @hyperlogloghyperlogloghyperloglog的相关操作
help @cluster集群集群的相关操作
help @geo地理位置地理位置的相关操作
help @streamstream的相关操作

generic类命令

命令概览

  DEL key [key ...]
  summary: 删除key
  summary: Delete a key
  since: 1.0.0

  DUMP key
  summary: 返回指定key的序列化值
  summary: Return a serialized version of the value stored at the specified key.
  since: 2.6.0

  EXISTS key [key ...]
  summary: 检查指定key是否存在
  summary: Determine if a key exists
  since: 1.0.0

  EXPIRE key seconds
  summary: 设置指定key的过期秒数
  summary: Set a key's time to live in seconds
  since: 1.0.0

  EXPIREAT key timestamp
  summary: 设置指定key的过期UNIX时间戳
  summary: Set the expiration for a key as a UNIX timestamp
  since: 1.2.0

  KEYS pattern
  summary: 查找符合格式的所有keys
  summary: Find all keys matching the given pattern
  since: 1.0.0

  MIGRATE host port key| destination-db timeout [COPY] [REPLACE] [AUTH password] [AUTH2 username password] [KEYS key]
  summary: 将key从一个redis实例迁移到另一个,timeout时间单位是毫秒
  summary: Atomically transfer a key from a Redis instance to another one.
  since: 2.6.0
  warning: 将 key 原子性地从当前实例传送到目标实例的指定数据库上,一旦传送成功, key 会出现在目标实例上,而当前实例上的 key 会被删除。MIGRATE 命令是一个原子操作,它在执行的时候会阻塞进行迁移的两个实例,直到以下任意结果发生:迁移成功,迁移失败,等待超时。
  demo: MIGRATE 127.0.0.1 6080 mylist 0 10000 AUTH 123456 
  demo: MIGRATE 127.0.0.1 6080 "" 0 10000 AUTH 123456 KEYS key1 key2

  MOVE key db
  summary: 将key移动到另一个库
  summary: Move a key to another database
  since: 1.0.0

  OBJECT subcommand [arguments [arguments ...]]
  summary: 查看redis内部对象
  summary: Inspect the internals of Redis objects
  since: 2.2.3
  demo: OBJECT ENCODING mylist

  PERSIST key
  summary: 移除指定key的有效期,使其不过期
  summary: Remove the expiration from a key
  since: 2.2.0
  demo: PERSIST key1

  PEXPIRE key milliseconds
  summary: 设置指定key的过期毫秒数
  summary: Set a key's time to live in milliseconds
  since: 2.6.0

  PEXPIREAT key milliseconds-timestamp
  summary: 设置指定key的过期UNIX时间戳毫秒计
  summary: Set the expiration for a key as a UNIX timestamp specified in milliseconds
  since: 2.6.0

  PTTL key
  summary: 获取指定key的过期毫秒数
  summary: Get the time to live for a key in milliseconds
  since: 2.6.0

  RANDOMKEY -
  summary: 随机返回一个key
  summary: Return a random key from the keyspace
  since: 1.0.0

  RENAME key newkey
  summary: 重命名key
  summary: Rename a key
  since: 1.0.0

  RENAMENX key newkey
  summary: 仅当 newkey 不存在时,将 key改名为newkey 
  summary: Rename a key, only if the new key does not exist
  since: 1.0.0

  RESTORE key ttl serialized-value [REPLACE] [ABSTTL] [IDLETIME seconds] [FREQ frequency]
  summary: 反序列化给定的序列化值(由 DUMP 生成),并将它和给定的 key 关联
  summary: Create a key using the provided serialized value, previously obtained using DUMP.
  since: 2.6.0
  demo: restore key2 0 "\x00\x05hello\t\x00\xb3\x80\x8e\xba1\xb2C\xbb" REPLACE
  若key不存在,直接保存;若key存在,指定了REPLACE,可以保存成功,若key存在,未指定REPLACE,则报错。

  SCAN cursor [MATCH pattern] [COUNT count] [TYPE type]
  summary: 遍历各个key
  summary: Incrementally iterate the keys space
  since: 2.8.0
  demo: scan 0 MATCH key* COUNT 10 TYPE string

  SORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]
  summary: 排序list,set,sorted set 的element
  summary: Sort the elements in a list, set or sorted set
  since: 1.0.0
  demo: SORT mylist limit 0 3 DESC store mylist2

  TOUCH key [key ...]
  summary: 返回被更新的 key 个数
  summary: Alters the last access time of a key(s). Returns the number of existing keys specified.
  since: 3.2.1

  TTL key
  summary: 返回指定给的剩余有效时间,单位秒
  summary: Get the time to live for a key
  since: 1.0.0

  TYPE key
  summary: 确定指定key的类型
  summary: Determine the type stored at key
  since: 1.0.0

  UNLINK key [key ...]
  summary: 在另一个线程异步的删除key,类似del,但是是非阻塞的
  summary: Delete a key asynchronously in another thread. Otherwise it is just as DEL, but non blocking.
  since: 4.0.0

  WAIT numreplicas timeout
  summary: 用来阻塞当前客户端,直到所有先前的写入命令成功传输并且至少由指定数量的从节点复制完成。
  summary: Wait for the synchronous replication of all the write commands sent in the context of the current connection
  since: 3.0.0

重点命令

命令说明备注
DEL key [key ...]删除key常用
EXISTS key [key ...]检查指定key是否存在常用
PEXPIRE设置指定key的过期毫秒数常用
SCAN遍历各个key常用
TTL key返回指定给的剩余有效时间,单位秒常考
TYPE key确定key的类型⭐️
UNLINK key [key ...]异步非阻塞删除常考
KEYS查找符合格式的所有keys常考
OBJECT subcommand查看redis内部对象高阶
MOVE key db迁移其他库高阶
MIGRATE迁移到其他实例高阶

string类命令

命令概览

  APPEND key value
  summary: 拼接
  summary: Append a value to a key
  since: 2.0.0

  BITCOUNT key [start end]
  summary: 统计字符串被设置为1的bit数
  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: 对字符串执行任意位进行操作
  summary: Perform arbitrary bitfield integer operations on strings
  since: 3.2.0

  BITOP operation destkey key [key ...]
  summary: 位操作
  summary: Perform bitwise operations between strings
  since: 2.6.0

  BITPOS key bit [start] [end]
  summary: 返回字符串里面第一个被设置为1或者0的bit位
  summary: Find first bit set or clear in a string
  since: 2.8.7

  DECR key
  summary: 自减1
  summary: Decrement the integer value of a key by one
  since: 1.0.0

  DECRBY key decrement
  summary: 减去指定值
  summary: Decrement the integer value of a key by the given number
  since: 1.0.0

  GET key
  summary: 获取指定key的value
  summary: Get the value of a key
  since: 1.0.0

  GETBIT key offset
  summary: 获取指定key指定偏移量的bit值
  summary: Returns the bit value at offset in the string value stored at key
  since: 2.2.0

  GETRANGE key start end
  summary: 获取某个key指定范围的值,类似substring
  summary: Get a substring of the string stored at a key
  since: 2.4.0

  GETSET key value
  summary: 设置某个value并返回老的value
  summary: Set the string value of a key and return its old value
  since: 1.0.0

  INCR key
  summary: 自增1
  summary: Increment the integer value of a key by one
  since: 1.0.0

  INCRBY key increment  
  summary: 自增指定的整数值
  summary: Increment the integer value of a key by the given amount
  since: 1.0.0

  INCRBYFLOAT key increment
  summary: 自增指定的浮点值
  summary: Increment the float value of a key by the given amount
  since: 2.6.0

  MGET key [key ...]
  summary: 批量获取值
  summary: Get the values of all the given keys
  since: 1.0.0

  MSET key value [key value ...]
  summary: 批量设置值
  summary: Set multiple keys to multiple values
  since: 1.0.1

  MSETNX key value [key value ...]
  summary: 仅当任意key不存在时,批量设置值
  summary: Set multiple keys to multiple values, only if none of the keys exist
  since: 1.0.1

  PSETEX key milliseconds value
  summary: 设置一个带有效期的值,时间单位为:毫秒
  summary: Set the value and expiration in milliseconds of a key
  since: 2.6.0

  SET key value [EX seconds|PX milliseconds|KEEPTTL] [NX|XX]
  summary: 设置值
  summary: Set the string value of a key
  since: 1.0.0

  SETBIT key offset value
  summary: 位设置值
  summary: Sets or clears the bit at offset in the string value stored at key
  since: 2.2.0

  SETEX key seconds value
  summary: 设置一个带有效期的值,时间单位为:秒
  summary: Set the value and expiration of a key
  since: 2.0.0

  SETNX key value
  summary: 仅当key不存在时,设置值
  summary: Set the value of a key, only if the key does not exist
  since: 1.0.0

  SETRANGE key offset value
  summary: 覆盖指定偏移量的值
  summary: Overwrite part of a string at key starting at the specified offset
  since: 2.2.0

  STRALGO LCS algo-specific-argument [algo-specific-argument ...]
  summary: 用来实现基于字符串的复杂算法。目前的唯一实现是 LCS 算法(longest common subsequence(最长公共子序列)
	summary: Run algorithms (currently LCS) against strings
  since: 6.0.0

  STRLEN key
  summary: 获取指定key的长度
  summary: Get the length of the value stored in a key
  since: 2.2.0

list类命令

  BLPOP key [key ...] timeout
  summary: 弹出第一个element,若集合为空,阻塞直至有element
  summary: Remove and get the first element in a list, or block until one is available
  since: 2.0.0

  BRPOP key [key ...] timeout
  summary: 弹出最后一个element,若集合为空,阻塞直至有element
  summary: Remove and get the last element in a list, or block until one is available
  since: 2.0.0

  BRPOPLPUSH source destination timeout
  summary: 从list弹出一个element,压入到另一个list,若集合为空,阻塞直至有element
  summary: Pop an element from a list, push it to another list and return it; or block until one is available
  since: 2.2.0

  LINDEX key index
  summary: 获取某个key的第index个element
  summary: Get an element from a list by its index
  since: 1.0.0

  LINSERT key BEFORE|AFTER pivot element
  summary: 插入element到指定element前或者后
  summary: Insert an element before or after another element in a list
  since: 2.2.0

  LLEN key
  summary: 获取elementlist的长度
  summary: Get the length of a list
  since: 1.0.0

  LPOP key
  summary: 移除list的第一个element,并返回
  summary: Remove and get the first element in a list
  since: 1.0.0

  LPOS key element [RANK rank] [COUNT num-matches] [MAXLEN len]
  summary: 返回列表 key 中匹配给定 element 成员的索引
  summary: Return the index of matching elements on a list
  since: 6.0.6

  LPUSH key element [element ...]
  summary: 压入一个或者多个element到list中
  summary: Prepend one or multiple elements to a list
  since: 1.0.0

  LPUSHX key element [element ...]
  summary: 仅当list存在时,压入一个或者多个element到list中
  summary: Prepend an element to a list, only if the list exists
  since: 2.2.0

  LRANGE key start stop
  summary: 获取list指定范围的elements
  summary: Get a range of elements from a list
  since: 1.0.0

  LREM key count element
  summary: 从列表 key 中删除前 count 个值等于 element 的元素
  summary: Remove elements from a list
  since: 1.0.0

  LSET key index element
  summary: 设置列表 key 中 index 位置的元素值为 element
  summary: Set the value of an element in a list by its index
  since: 1.0.0

  LTRIM key start stop
  summary: 用于修剪(trim)一个已存在的 list,这样 list 就会只包含指定范围的指定元素
  summary: Trim a list to the specified range
  since: 1.0.0

  RPOP key
  summary: 移除list的最后个element,并返回
  summary: Remove and get the last element in a list
  since: 1.0.0

  RPOPLPUSH source destination
  summary: 从list弹出最后一个element,压入到另一个list,若集合为空,阻塞直至有element
  summary: Remove the last element in a list, prepend it to another list and return it
  since: 1.2.0

  RPUSH key element [element ...]
  summary: 往list后拼接一个或者多个element
  summary: Append one or multiple elements to a list
  since: 1.0.0

  RPUSHX key element [element ...]
  summary: 仅当元素存在时,往list后拼接一个或者多个element
  summary: Append an element to a list, only if the list exists
  since: 2.2.0

set类命令

  SADD key member [member ...]
  summary: 往set添加一个或者多个member
  summary: Add one or more members to a set
  since: 1.0.0

  SCARD key
  summary: 获取 set 的 members 数量 
  summary: Get the number of members in a set
  since: 1.0.0

  SDIFF key [key ...]
  summary: 多个set 的差集  
  summary: Subtract multiple sets
  since: 1.0.0

  SDIFFSTORE destination key [key ...]
  summary:  多个set 的差集 并输出到新的set  
  summary: Subtract multiple sets and store the resulting set in a key
  since: 1.0.0

  SINTER key [key ...]
  summary: 多个set 的交集  
  summary: Intersect multiple sets
  since: 1.0.0

  SINTERSTORE destination key [key ...]
  summary: 多个set 的交集 并输出到新的set  
  summary: Intersect multiple sets and store the resulting set in a key
  since: 1.0.0

  SISMEMBER key member
  summary:  确定一个set中是否包含某个member  
  summary: Determine if a given value is a member of a set
  since: 1.0.0

  SMEMBERS key
  summary: 获取所有的 members  
  summary: Get all the members in a set
  since: 1.0.0

  SMOVE source destination member
  summary: 移动set的一个member到新的 set 
  summary: Move a member from one set to another
  since: 1.0.0

  SPOP key [count]
  summary: 从set中随机移除一个或者多个member并返回  
  summary: Remove and return one or multiple random members from a set
  since: 1.0.0

  SRANDMEMBER key [count]
  summary: 从set随机获取一个或者多个member    
  summary: Get one or multiple random members from a set
  since: 1.0.0

  SREM key member [member ...]
  summary: 从set中随机移除一个或者多个member  
  summary: Remove one or more members from a set
  since: 1.0.0

  SSCAN key cursor [MATCH pattern] [COUNT count]
  summary: 迭代Set 的元素  
  summary: Incrementally iterate Set elements
  since: 2.8.0

  SUNION key [key ...]
  summary: 多个set的并集  
  summary: Add multiple sets
  since: 1.0.0

  SUNIONSTORE destination key [key ...]
  summary: 多个set的并集并输出到新的set  
  summary: Add multiple sets and store the resulting set in a key
  since: 1.0.0

sorted_set类命令

  BZPOPMAX key [key ...] timeout
  summary: 从一个或者多个 sorted sets 移除并返回最高分的member,若为空,阻塞直到可用
  summary: Remove and return the member with the highest score from one or more sorted sets, or block until one is available
  since: 5.0.0

  BZPOPMIN key [key ...] timeout
  summary:  从一个或者多个 sorted sets 移除并返回最低分的member,若为空,阻塞直到可用  
  summary: Remove and return the member with the lowest score from one or more sorted sets, or block until one is available
  since: 5.0.0

  ZADD key [NX|XX] [CH] [INCR] score member [score member ...]
  summary: 添加一个或者多个 members 到 sorted set
  summary: Add one or more members to a sorted set, or update its score if it already exists
  since: 1.2.0

  ZCARD key
  summary: 获取sorted set中members 的数量
  summary: Get the number of members in a sorted set
  since: 1.2.0

  ZCOUNT key min max
  summary: 返回有序集 key 中, score 值在 min 和 max 之间(默认包括 score 值等于 min 或 max )的成员的数
  summary: Count the members in a sorted set with scores within the given values
  since: 2.0.0

  ZINCRBY key increment member
  summary: 自增 sorted set 的 member
  summary: Increment the score of a member in a sorted set
  since: 1.2.0

  ZINTERSTORE destination numkeys key [key ...] [WEIGHTS weight] [AGGREGATE SUM|MIN|MAX]
  summary:  取多个sorted sets 的交集并保存到destination
  summary: Intersect multiple sorted sets and store the resulting sorted set in a new key
  since: 2.0.0

  ZLEXCOUNT key min max
  summary:  返回有序集中值在 min 和max之间的成员个数 
  summary: Count the number of members in a sorted set between a given lexicographical range
  since: 2.8.9

  ZPOPMAX key [count]
  summary: 移除并返回sorted set 最高分members   
  summary: Remove and return members with the highest scores in a sorted set
  since: 5.0.0

  ZPOPMIN key [count]
  summary: 移除并返回sorted set 最低分members  
  summary: Remove and return members with the lowest scores in a sorted set
  since: 5.0.0

  ZRANGE key start stop [WITHSCORES]
  summary: 返回有序集中,指定区间内的members,其中成员的按分数值递增(从小到大)来排序,具有相同分数值的成员按字典序(lexicographical order )来排列 
  summary: Return a range of members in a sorted set, by index
  since: 1.2.0

  ZRANGEBYLEX key min max [LIMIT offset count]
  summary: 返回有序集中,指定区间内的members,按照字典序
  summary: Return a range of members in a sorted set, by lexicographical range
  since: 2.8.9

  ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]
  summary: 返回有序集 key 中,所有 score 值介于 min 和 max 之间(包括等于 min 或 max )的members。有序集members按 score 值递增(从小到大)次序排列  
  summary: Return a range of members in a sorted set, by score
  since: 1.0.5

  ZRANK key member
  summary: 确定sorted set 中member的排名  
  summary: Determine the index of a member in a sorted set
  since: 2.0.0

  ZREM key member [member ...]
  summary: 移除 sorted set 中一个或多个member 
  summary: Remove one or more members from a sorted set
  since: 1.2.0

  ZREMRANGEBYLEX key min max
  summary: 删除成员名称按字典由低到高排序介于min 和 max 之间的所有members  
  summary: Remove all members in a sorted set between the given lexicographical range
  since: 2.8.9

  ZREMRANGEBYRANK key start stop
  summary: 移除有序集key中,指定排名(rank)区间 start 和 stop 内的所有成员  
  summary: Remove all members in a sorted set within the given indexes
  since: 2.0.0

  ZREMRANGEBYSCORE key min max
  summary: 移除有序集key中,指定分数内的所有成员  
  summary: Remove all members in a sorted set within the given scores
  since: 1.2.0

  ZREVRANGE key start stop [WITHSCORES]
  summary: 返回有序集中,指定区间内的members,其中成员的按分数值递增(从大到小)来排序,具有相同分数值的成员按字典序(lexicographical order )来排列   
  summary: Return a range of members in a sorted set, by index, with scores ordered from high to low
  since: 1.2.0

  ZREVRANGEBYLEX key max min [LIMIT offset count]
  summary: 返回有序集中,指定区间内的members,按照字典序,从高到低  
  summary: Return a range of members in a sorted set, by lexicographical range, ordered from higher to lower strings.
  since: 2.8.9

  ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count]
  summary: 返回有序集中,指定区间内的members,按照分数,从高到低   
  summary: Return a range of members in a sorted set, by score, with scores ordered from high to low
  since: 2.2.0

  ZREVRANK key member
  summary: 确定sorted set 中member从高到低的排名    
  summary: Determine the index of a member in a sorted set, with scores ordered from high to low
  since: 2.0.0

  ZSCAN key cursor [MATCH pattern] [COUNT count]
  summary:   
  summary: Incrementally iterate sorted sets elements and associated scores
  since: 2.8.0

  ZSCORE key member
  summary: 用于增量遍历集合中的元素  
  summary: Get the score associated with the given member in a sorted set
  since: 1.2.0

  ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS weight] [AGGREGATE SUM|MIN|MAX]
  summary: 用于计算给定的numkeys个有序集合的并集,并且把结果放到destination中  
  summary: Add multiple sorted sets and store the resulting sorted set in a new key
  since: 2.0.0

hash 类命令

  HDEL key field [field ...]
  summary: 删除哈希表 key 中的一个或多个指定字段,不存在的字段将被忽略  
  summary: Delete one or more hash fields
  since: 2.0.0

  HEXISTS key field
  summary: 检查哈希表 key 中是否存在指定字段  
  summary: Determine if a hash field exists
  since: 2.0.0

  HGET key field
  summary: 获取哈希表 key 中指定字段 的值
  summary: Get the value of a hash field
  since: 2.0.0

  HGETALL key
  summary: 获取哈希表 key 中全部字段和值  
  summary: Get all the fields and values in a hash
  since: 2.0.0

  HINCRBY key field increment
  summary: 使哈希表 key 中指定字段自增1  
  summary: Increment the integer value of a hash field by the given number
  since: 2.0.0

  HINCRBYFLOAT key field increment
  summary: 使哈希表 key 中指定字段自增 increment的浮点数 
  summary: Increment the float value of a hash field by the given amount
  since: 2.6.0

  HKEYS key
  summary: 获取哈希表 key 中全部的字段    
  summary: Get all the fields in a hash
  since: 2.0.0

  HLEN key
  summary: 获取哈希表 key 中全部的字段的数量      
  summary: Get the number of fields in a hash
  since: 2.0.0

  HMGET key field [field ...]
  summary: 批量获取指定一个或多个字段的值  
  summary: Get the values of all the given hash fields
  since: 2.0.0

  HMSET key field value [field value ...]
  summary: 批量设置指定一个或多个字段的值    
  summary: Set multiple hash fields to multiple values
  since: 2.0.0

  HSCAN key cursor [MATCH pattern] [COUNT count]
  summary: 增量遍历哈希表  
  summary: Incrementally iterate hash fields and associated values
  since: 2.8.0

  HSET key field value [field value ...]
  summary: 设置哈希表的值  
  summary: Set the string value of a hash field
  since: 2.0.0

  HSETNX key field value
  summary: 仅当哈希表中指定字段不存在时才成功设置字段的字段和值  
  summary: Set the value of a hash field, only if the field does not exist
  since: 2.0.0

  HSTRLEN key field
  summary: 获取哈希表中指定字段值的长度  
  summary: Get the length of the value of a hash field
  since: 3.2.0

  HVALS key
  summary: 获取哈希表 key 中全部字段的值   
  summary: Get all the values in a hash
  since: 2.0.0

pubsub 类命令

  PSUBSCRIBE pattern [pattern ...]
  summary: 用于订阅一个或多个符合给定模式的channel
  summary: Listen for messages published to channels matching the given patterns
  since: 2.0.0

  PUBLISH channel message
  summary: 发布消息到指定channel 
  summary: Post a message to a channel
  since: 2.0.0

  PUBSUB subcommand [argument [argument ...]]
  summary: 用于查看发布与订阅系统状态的命令, 它由数个不同格式的子命令组成  
  summary: Inspect the state of the Pub/Sub subsystem
  since: 2.8.0

  PUNSUBSCRIBE [pattern [pattern ...]]
  summary: 用于客户端退订所有给定模式
  summary: Stop listening for messages posted to channels matching the given patterns
  since: 2.0.0

  SUBSCRIBE channel [channel ...]
  summary: 用于订阅给定的一个或多个频道的信息 
  summary: Listen for messages published to the given channels
  since: 2.0.0

  UNSUBSCRIBE [channel [channel ...]]
  summary: 用于指示客户端退订给定的频道  
  summary: Stop listening for messages posted to the given channels
  since: 2.0.0

transactions 类命令

  DISCARD -
  summary: 取消事务,放弃执行事务队列内的所有命令,恢复连接为非 (transaction) 模式
  summary: Discard all commands issued after MULTI
  since: 2.0.0

  EXEC -
  summary: 用于执行事务 (transaction )队列内的所有命
  summary: Execute all commands issued after MULTI
  since: 1.2.0

  MULTI -
  summary: 用于标记一个事务块的开始
  summary: Mark the start of a transaction block
  since: 1.2.0

  UNWATCH -
  summary: 用于取消 WATCH 命令对所有 key 的监视
  summary: Forget about all watched keys
  since: 2.2.0

  WATCH key [key ...]
  summary: 用于标记要监视的key,以便有条件地执行事务(更多参考transaction)
  summary: Watch the given keys to determine execution of the MULTI/EXEC block
  since: 2.2.0

connection 类命令

  AUTH [username] password
  summary: 到服务端认证 
  summary: Authenticate to the server
  since: 1.0.0

  CLIENT CACHING YES|NO
  summary:   
  summary: Instruct the server about tracking or not keys in the next request
  since: 6.0.0

  CLIENT GETNAME -
  summary:   
  summary: Get the current connection name
  since: 2.6.9

  CLIENT GETREDIR -
  summary:   
  summary: Get tracking notifications redirection client ID if any
  since: 6.0.0

  CLIENT ID -
  summary:   
  summary: Returns the client ID for the current connection
  since: 5.0.0

  CLIENT KILL [ip:port] [ID client-id] [TYPE normal|master|slave|pubsub] [USER username] [ADDR ip:port] [SKIPME yes/no]
  summary:   
  summary: Kill the connection of a client
  since: 2.4.0

  CLIENT LIST [TYPE normal|master|replica|pubsub]
  summary:   
  summary: Get the list of client connections
  since: 2.4.0

  CLIENT PAUSE timeout
  summary:   
  summary: Stop processing commands from clients for some time
  since: 2.9.50

  CLIENT REPLY ON|OFF|SKIP
  summary:   
  summary: Instruct the server whether to reply to commands
  since: 3.2.0

  CLIENT SETNAME connection-name
  summary:   
  summary: Set the current connection name
  since: 2.6.9

  CLIENT TRACKING ON|OFF [REDIRECT client-id] [PREFIX prefix [PREFIX prefix ...]] [BCAST] [OPTIN] [OPTOUT] [NOLOOP]
  summary:   
  summary: Enable or disable server assisted client side caching support
  since: 6.0.0

  CLIENT UNBLOCK client-id [TIMEOUT|ERROR]
  summary: 
  summary: Unblock a client blocked in a blocking command from a different connection
  since: 5.0.0

  ECHO message
  summary: 输出指定字符串   
  summary: Echo the given string
  since: 1.0.0

  HELLO protover [AUTH username password] [SETNAME clientname]
  summary: 切换Redis协议  
  summary: switch Redis protocol
  since: 6.0.0

  PING [message]
  summary: 发送PING到服务端  
  summary: Ping the server
  since: 1.0.0

  QUIT -
  summary: 退出  
  summary: Close the connection
  since: 1.0.0

  SELECT index
  summary: 切换当前连接选择的库  
  summary: Change the selected database for the current connection
  since: 1.0.0

server 类命令

  ACL CAT [categoryname]
  summary:   
  summary: List the ACL categories or the commands inside a category
  since: 6.0.0

  ACL DELUSER username [username ...]
  summary:   
  summary: Remove the specified ACL users and the associated rules
  since: 6.0.0

  ACL GENPASS [bits]
  summary:   
  summary: Generate a pseudorandom secure password to use for ACL users
  since: 6.0.0

  ACL GETUSER username
  summary:   
  summary: Get the rules for a specific ACL user
  since: 6.0.0

  ACL HELP -
  summary:   
  summary: Show helpful text about the different subcommands
  since: 6.0.0

  ACL LIST -
  summary:   
  summary: List the current ACL rules in ACL config file format
  since: 6.0.0

  ACL LOAD -
  summary:   
  summary: Reload the ACLs from the configured ACL file
  since: 6.0.0

  ACL LOG [count or RESET]
  summary:
  summary: List latest events denied because of ACLs in place
  since: 6.0.0

  ACL SAVE -
  summary:
  summary: Save the current ACL rules in the configured ACL file
  since: 6.0.0

  ACL SETUSER username [rule [rule ...]]
  summary:
  summary: Modify or create the rules for a specific ACL user
  since: 6.0.0

  ACL USERS -
  summary:
  summary: List the username of all the configured ACL rules
  since: 6.0.0

  ACL WHOAMI -
  summary:
  summary: Return the name of the user associated to the current connection
  since: 6.0.0

  BGREWRITEAOF -
  summary:
  summary: Asynchronously rewrite the append-only file
  since: 1.0.0

  BGSAVE [SCHEDULE]
  summary:
  summary: Asynchronously save the dataset to disk
  since: 1.0.0

  COMMAND -
  summary:
  summary: Get array of Redis command details
  since: 2.8.13

  COMMAND COUNT -
  summary:
  summary: Get total number of Redis commands
  since: 2.8.13

  COMMAND GETKEYS -
  summary:
  summary: Extract keys given a full Redis command
  since: 2.8.13

  COMMAND INFO command-name [command-name ...]
  summary:
  summary: Get array of specific Redis command details
  since: 2.8.13

  CONFIG GET parameter
  summary:
  summary: Get the value of a configuration parameter
  since: 2.0.0

  CONFIG RESETSTAT -
  summary:
  summary: Reset the stats returned by INFO
  since: 2.0.0

  CONFIG REWRITE -
  summary:
  summary: Rewrite the configuration file with the in memory configuration
  since: 2.8.0

  CONFIG SET parameter value
  summary:
  summary: Set a configuration parameter to the given value
  since: 2.0.0

  DBSIZE -
  summary:
  summary: Return the number of keys in the selected database
  since: 1.0.0

  DEBUG OBJECT key
  summary:
  summary: Get debugging information about a key
  since: 1.0.0

  DEBUG SEGFAULT -
  summary: 
  summary: Make the server crash
  since: 1.0.0

  FLUSHALL [ASYNC]
  summary: 移除库所有的keys
  summary: Remove all keys from all databases
  since: 1.0.0

  FLUSHDB [ASYNC]
  summary: 移除当前库全部的keys
  summary: Remove all keys from the current database
  since: 1.0.0

  INFO [section]
  summary: 以一种易于理解和阅读的格式,返回关于Redis服务器的各种信息和统计数值
  summary: Get information and statistics about the server
  since: 1.0.0

  LASTSAVE -
  summary: 以 UNIX 时间戳格式返回最近一次 Redis 成功将数据保存到磁盘上的时间
  summary: Get the UNIX time stamp of the last successful save to disk
  since: 1.0.0

  LATENCY DOCTOR -
  summary: 返回易于理解和阅读延迟分析报告 
  summary: Return a human readable latency analysis report.
  since: 2.8.13

  LATENCY GRAPH event
  summary: 返回时间的延迟图标
  summary: Return a latency graph for the event.
  since: 2.8.13

  LATENCY HELP -
  summary: 延迟帮助
  summary: Show helpful text about the different subcommands.
  since: 2.8.13

  LATENCY HISTORY event
  summary: 延迟历史时间
  summary: Return timestamp-latency samples for the event.
  since: 2.8.13

  LATENCY LATEST -
  summary: 返回最近的延迟事件
  summary: Return the latest latency samples for all events.
  since: 2.8.13

  LATENCY RESET [event [event ...]]
  summary: 重置一个或多个时间的延时数据
  summary: Reset latency data for one or more events.
  since: 2.8.13

  LOLWUT [VERSION version]
  summary: 
  summary: Display some computer art and the Redis version
  since: 5.0.0

  MEMORY DOCTOR -
  summary: 输出内存问题报告
  summary: Outputs memory problems report
  since: 4.0.0

  MEMORY HELP -
  summary: 内存帮助
  summary: Show helpful text about the different subcommands
  since: 4.0.0

  MEMORY MALLOC-STATS -
  summary: 显示分配器内部统计信息
  summary: Show allocator internal stats
  since: 4.0.0

  MEMORY PURGE -
  summary: 要求分配器释放内存
  summary: Ask the allocator to release memory
  since: 4.0.0

  MEMORY STATS -
  summary: 展示内存使用细节
  summary: Show memory usage details
  since: 4.0.0

  MEMORY USAGE key [SAMPLES count]
  summary: 展示key的内存使用情况
  summary: Estimate the memory usage of a key
  since: 4.0.0

  MODULE LIST -
  summary: 展示服务端加载的所有模块
  summary: List all modules loaded by the server
  since: 4.0.0

  MODULE LOAD path [arg]
  summary: 加载一个模块
  summary: Load a module
  since: 4.0.0

  MODULE UNLOAD name
  summary: 卸载一个模块
  summary: Unload a module
  since: 4.0.0

  MONITOR -
  summary: 实时监听服务端收到的所有请求
  summary: Listen for all requests received by the server in real time
  since: 1.0.0

  PSYNC replicationid offset
  summary: 用于复制功能(replication)的内部命令。用于在 slave 节点上执行这个命令向 master 节点请求复制流
  summary: Internal command used for replication
  since: 2.8.0

  REPLICAOF host port
  summary: 可以在线修改当前服务器的复制设置
  summary: Make the server a replica of another instance, or promote it as master.
  since: 5.0.0

  ROLE -
  summary: 返回当前实例的角色
  summary: Return the role of the instance in the context of replication
  since: 2.8.12

  SAVE -
  summary: 同步保存数据到磁盘
  summary: Synchronously save the dataset to disk
  since: 1.0.0

  SHUTDOWN [NOSAVE|SAVE]
  summary: 同步保存数据到磁盘并停止服务
  summary: Synchronously save the dataset to disk and then shut down the server
  since: 1.0.0

  SLAVEOF host port
  summary: 可以将当前服务器转变为指定服务器的从属服务器
  summary: Make the server a replica of another instance, or promote it as master. Deprecated starting with Redis 5. Use REPLICAOF instead.
  since: 1.0.0

  SLOWLOG subcommand [argument]
  summary: 慢日志
  summary: Manages the Redis slow queries log
  since: 2.2.12

  SWAPDB index1 index2
  summary: 用于交换两个数据库,命令执行后,连接到某一数据库的客户端可以立刻看到另外一个数据库的数据
  summary: Swaps two Redis databases
  since: 4.0.0

  SYNC -
  summary: 内部命令用于复制
  summary: Internal command used for replication
  since: 1.0.0

  TIME -
  summary: 返回当前服务器时间
  summary: Return the current server time
  since: 2.6.0

scripting 类命令

  EVAL script numkeys key [key ...] arg [arg ...]
  summary:  使用 Lua 解释器执行脚本
  summary: Execute a Lua script server side
  since: 2.6.0

  EVALSHA sha1 numkeys key [key ...] arg [arg ...]
  summary:  使用 Lua 解释器执行脚本  
  summary: Execute a Lua script server side
  since: 2.6.0

  SCRIPT DEBUG YES|SYNC|NO
  summary:  设置DUBE模式执行脚本 
  summary: Set the debug mode for executed scripts.
  since: 3.2.0

  SCRIPT EXISTS sha1 [sha1 ...]
  summary: 用于校验指定的脚本是否缓存在脚本缓存当中
  summary: Check existence of scripts in the script cache.
  since: 2.6.0

  SCRIPT FLUSH -
  summary: 用于清除所有 Lua 脚本缓存。  
  summary: Remove all the scripts from the script cache.
  since: 2.6.0

  SCRIPT KILL -
  summary: 杀掉正在执行的脚本  
  summary: Kill the script currently in execution.
  since: 2.6.0

  SCRIPT LOAD script
  summary:  加载脚本到脚本缓存 
  summary: Load the specified Lua script into the script cache.
  since: 2.6.0

hyperloglog 类命令

  PFADD key element [element ...]
  summary: 将所有元素参数添加到 HyperLogLog 数据结构中  
  summary: Adds the specified elements to the specified HyperLogLog.
  since: 2.8.9

  PFCOUNT key [key ...]
  summary: 返回给定 HyperLogLog 的基数估算值  
  summary: Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s).
  since: 2.8.9

  PFMERGE destkey sourcekey [sourcekey ...]
  summary: 将多个HyperLogLog合并为一个HyperLogLog,合并后的HyperLogLog的基数估算值是通过对所有给定HyperLogLog进行并集计算得出的  
  summary: Merge N different HyperLogLogs into a single one.
  since: 2.8.9

cluster 类命令

  CLUSTER ADDSLOTS slot [slot ...]
  summary:   
  summary: Assign new hash slots to receiving node
  since: 3.0.0

  CLUSTER BUMPEPOCH -
  summary:   
  summary: Advance the cluster config epoch
  since: 3.0.0

  CLUSTER COUNT-FAILURE-REPORTS node-id
  summary:   
  summary: Return the number of failure reports active for a given node
  since: 3.0.0

  CLUSTER COUNTKEYSINSLOT slot
  summary:   
  summary: Return the number of local keys in the specified hash slot
  since: 3.0.0

  CLUSTER DELSLOTS slot [slot ...]
  summary:   
  summary: Set hash slots as unbound in receiving node
  since: 3.0.0

  CLUSTER FAILOVER [FORCE|TAKEOVER]
  summary:   
  summary: Forces a replica to perform a manual failover of its master.
  since: 3.0.0

  CLUSTER FLUSHSLOTS -
  summary:   
  summary: Delete a node's own slots information
  since: 3.0.0

  CLUSTER FORGET node-id
  summary:   
  summary: Remove a node from the nodes table
  since: 3.0.0

  CLUSTER GETKEYSINSLOT slot count
  summary:   
  summary: Return local key names in the specified hash slot
  since: 3.0.0

  CLUSTER INFO -
  summary:   
  summary: Provides info about Redis Cluster node state
  since: 3.0.0

  CLUSTER KEYSLOT key
  summary:   
  summary: Returns the hash slot of the specified key
  since: 3.0.0

  CLUSTER MEET ip port
  summary:   
  summary: Force a node cluster to handshake with another node
  since: 3.0.0

  CLUSTER MYID -
  summary:   
  summary: Return the node id
  since: 3.0.0

  CLUSTER NODES -
  summary:   
  summary: Get Cluster config for the node
  since: 3.0.0

  CLUSTER REPLICAS node-id
  summary:   
  summary: List replica nodes of the specified master node
  since: 5.0.0

  CLUSTER REPLICATE node-id
  summary:   
  summary: Reconfigure a node as a replica of the specified master node
  since: 3.0.0

  CLUSTER RESET [HARD|SOFT]
  summary:   
  summary: Reset a Redis Cluster node
  since: 3.0.0

  CLUSTER SAVECONFIG -
  summary:   
  summary: Forces the node to save cluster state on disk
  since: 3.0.0

  CLUSTER SET-CONFIG-EPOCH config-epoch
  summary:   
  summary: Set the configuration epoch in a new node
  since: 3.0.0

  CLUSTER SETSLOT slot IMPORTING|MIGRATING|STABLE|NODE [node-id]
  summary:   
  summary: Bind a hash slot to a specific node
  since: 3.0.0

  CLUSTER SLAVES node-id
  summary:   
  summary: List replica nodes of the specified master node
  since: 3.0.0

  CLUSTER SLOTS -
  summary:   
  summary: Get array of Cluster slot to node mappings
  since: 3.0.0

  READONLY -
  summary:   
  summary: Enables read queries for a connection to a cluster replica node
  since: 3.0.0

  READWRITE -
  summary:   
  summary: Disables read queries for a connection to a cluster replica node
  since: 3.0.0

geo 类命令

  GEOADD key longitude latitude member [longitude latitude member ...]
  summary: 添加一个或者多个地理信息 member   
  summary: Add one or more geospatial items in the geospatial index represented using a sorted set
  since: 3.2.0

  GEODIST key member1 member2 [m|km|ft|mi]
  summary: 返回两个地理信息之间的距离
  summary: Returns the distance between two members of a geospatial index
  since: 3.2.0

  GEOHASH key member [member ...]
  summary: 用于返回一个或多个位置元素的 Geohash 表示  
  summary: Returns members of a geospatial index as standard geohash strings
  since: 3.2.0

  GEOPOS key member [member ...]
  summary: 返回经纬度  
  summary: Returns longitude and latitude of members of a geospatial index
  since: 3.2.0

  GEORADIUS key longitude latitude radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE key] [STOREDIST key]
  summary: 以给定的经纬度为中心, 返回键包含的位置元素当中, 与中心的距离不超过给定最大距离的所有位置元素   
  summary: Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point
  since: 3.2.0

  GEORADIUSBYMEMBER key member radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE key] [STOREDIST key]
  summary: 找出位于指定范围内的元素,但是 georadiusbymember 的中心点是由给定的位置元素决定的,而不是使用经度和纬度来决定中心点   
  summary: Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member
  since: 3.2.0

stream 类命令

  XACK key group ID [ID ...]
  summary:   
  summary: Marks a pending message as correctly processed, effectively removing it from the pending entries list of the consumer group. Return value of the command is the number of messages successfully acknowledged, that is, the IDs we were actually able to resolve in the PEL.
  since: 5.0.0

  XADD key ID field value [field value ...]
  summary:   
  summary: Appends a new entry to a stream
  since: 5.0.0

  XCLAIM key group consumer min-idle-time ID [ID ...] [IDLE ms] [TIME ms-unix-time] [RETRYCOUNT count] [force] [justid]
  summary:   
  summary: Changes (or acquires) ownership of a message in a consumer group, as if the message was delivered to the specified consumer.
  since: 5.0.0

  XDEL key ID [ID ...]
  summary:   
  summary: Removes the specified entries from the stream. Returns the number of items actually deleted, that may be different from the number of IDs passed in case certain IDs do not exist.
  since: 5.0.0

  XGROUP [CREATE key groupname id-or-$] [SETID key groupname id-or-$] [DESTROY key groupname] [DELCONSUMER key groupname consumername]
  summary:   
  summary: Create, destroy, and manage consumer groups.
  since: 5.0.0

  XINFO [CONSUMERS key groupname] [GROUPS key] [STREAM key] [HELP]
  summary:   
  summary: Get information on streams and consumer groups
  since: 5.0.0

  XLEN key
  summary:   
  summary: Return the number of entires in a stream
  since: 5.0.0

  XPENDING key group [start end count] [consumer]
  summary:   
  summary: Return information and entries from a stream consumer group pending entries list, that are messages fetched but never acknowledged.
  since: 5.0.0

  XRANGE key start end [COUNT count]
  summary:   
  summary: Return a range of elements in a stream, with IDs matching the specified IDs interval
  since: 5.0.0

  XREAD [COUNT count] [BLOCK milliseconds] STREAMS key [key ...] id [id ...]
  summary:   
  summary: Return never seen elements in multiple streams, with IDs greater than the ones reported by the caller for each stream. Can block.
  since: 5.0.0

  XREADGROUP GROUP group consumer [COUNT count] [BLOCK milliseconds] [NOACK] STREAMS key [key ...] ID [ID ...]
  summary:   
  summary: Return new entries from a stream using a consumer group, or access the history of the pending entries for a given consumer. Can block.
  since: 5.0.0

  XREVRANGE key end start [COUNT count]
  summary:   
  summary: Return a range of elements in a stream, with IDs matching the specified IDs interval, in reverse order (from greater to smaller IDs) compared to XRANGE
  since: 5.0.0

  XTRIM key MAXLEN [~] count
  summary:   
  summary: Trims the stream to (approximately if '~' is passed) a certain size
  since: 5.0.0