一、键操作(keys)
DEL key [key ...] 删除一个keyDUMP key 导出key的值EXISTS key [key ...] 查询一个key是否存在EXPIRE key seconds 设置一个key的过期的秒数EXPIREAT key timestamp 设置一个UNIX时间戳的过期时间KEYS pattern 查找所有匹配给定的模式的键MIGRATE host port key destination-db timeout [COPY] [REPLACE] 原子性的将key从redis的一个实例移到另一个实例MOVE key db 移动一个key到另一个数据库OBJECT subcommand [arguments [arguments ...]] 检查内部的再分配对象PERSIST key 移除key的过期时间PEXPIRE key milliseconds 设置key的有效时间以毫秒为单位PEXPIREAT key milliseconds-timestamp 设置key的到期UNIX时间戳以毫秒为单位PTTL key 获取key的有效毫秒数RANDOMKEY 返回一个随机的keyRENAME key newkey 将一个key重命名RENAMENX key newkey 重命名一个key,新的key必须是不存在的keyRESTORE key ttl serialized-value [REPLACE] Create a key using the provided serialized value, previously obtained using DUMP.SORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination] 对队列、集合、有序集合排序TTL key 获取key的有效时间(单位:秒)TYPE key 获取key的存储类型WAIT numslaves timeout Wait for the synchronous replication of all the write commands sent in the context of the current connectionSCAN cursor [MATCH pattern] [COUNT count] 增量迭代key
二、服务器操作(server)
BGREWRITEAOF 异步重写追加文件命令BGSAVE 异步保存数据集到磁盘上CLIENT KILL [ip:port] [ID client-id] [TYPE normal|slave|pubsub] [ADDR ip:port] [SKIPME yes/no] 关闭客户端连接CLIENT LIST 获得客户端连接列表CLIENT GETNAME 获得当前连接名称CLIENT PAUSE timeout 暂停处理客户端命令CLIENT SETNAME connection-name 设置当前连接的名字COMMAND Get array of Redis command detailsCOMMAND COUNT Get total number of Redis commandsCOMMAND GETKEYS Extract keys given a full Redis commandCOMMAND INFO command-name [command-name ...] Get array of specific Redis command detailsCONFIG GET parameter 获取配置参数的值CONFIG REWRITE 从写内存中的配置文件CONFIG SET parameter value 设置配置文件CONFIG RESETSTAT 复位再分配使用info命令报告的统计DBSIZE 返回当前数据库里面的keys数量DEBUG OBJECT key 获取一个key的debug信息DEBUG SEGFAULT 使服务器崩溃命令FLUSHALL 清空所有数据库命令FLUSHDB 清空当前的数据库命令INFO [section] 获得服务器的详细信息LASTSAVE 获得最后一次同步磁盘的时间MONITOR 实时监控服务器ROLE Return the role of the instance in the context of replicationSAVE 同步数据到磁盘上SHUTDOWN [NOSAVE] [SAVE] 关闭服务SLAVEOF host port 指定当前服务器的主服务器SLOWLOG subcommand [argument] 管理再分配的慢查询日志SYNC 用于复制的内部命令TIME 返回当前服务器时间
三、字符串操作(strings)
APPEND key value 追加一个值到key上BITCOUNT key [start end] 统计字符串指定起始位置的字节数BITOP operation destkey key [key ...] Perform bitwise operations between stringsBITPOS key bit [start] [end] Find first bit set or clear in a stringDECR key 整数原子减1DECRBY key decrement 原子减指定的整数GET key 返回key的valueGETBIT key offset 返回位的值存储在关键的字符串值的偏移量。GETRANGE key start end 获取存储在key上的值的一个子字符串GETSET key value 设置一个key的value,并获取设置前的值INCR key 执行原子加1操作INCRBY key increment 执行原子增加一个整数INCRBYFLOAT key increment 执行原子增加一个浮点数MGET key [key ...] 获得所有key的值MSET key value [key value ...] 设置多个key valueMSETNX key value [key value ...] 设置多个key value,仅当key存在时PSETEX key milliseconds value Set the value and expiration in milliseconds of a keySET key value [EX seconds] [PX milliseconds] [NX|XX] 设置一个key的value值SETBIT key offset value Sets or clears the bit at offset in the string value stored at keySETEX key seconds value 设置key-value并设置过期时间(单位:秒)SETNX key value 设置的一个关键的价值,只有当该键不存在SETRANGE key offset value Overwrite part of a string at key starting at the specified offsetSTRLEN key 获取指定key值的长度
四、集群操作(cluster)
CLUSTER ADDSLOTS slot [slot ...] Assign new hash slots to receiving nodeCLUSTER COUNT-FAILURE-REPORTS node-id Return the number of failure reports active for a given nodeCLUSTER COUNTKEYSINSLOT slot Return the number of local keys in the specified hash slotCLUSTER DELSLOTS slot [slot ...] Set hash slots as unbound in receiving nodeCLUSTER FAILOVER [FORCE|TAKEOVER] Forces a slave to perform a manual failover of its master.CLUSTER FORGET node-id Remove a node from the nodes tableCLUSTER GETKEYSINSLOT slot count Return local key names in the specified hash slotCLUSTER INFO Provides info about Redis Cluster node stateCLUSTER KEYSLOT key Returns the hash slot of the specified keyCLUSTER MEET ip port Force a node cluster to handshake with another nodeCLUSTER NODES Get Cluster config for the nodeCLUSTER REPLICATE node-id Reconfigure a node as a slave of the specified master nodeCLUSTER RESET [HARD|SOFT] Reset a Redis Cluster nodeCLUSTER SAVECONFIG Forces the node to save cluster state on diskCLUSTER SET-CONFIG-EPOCH config-epoch Set the configuration epoch in a new nodeCLUSTER SETSLOT slot IMPORTING|MIGRATING|STABLE|NODE [node-id] Bind an hash slot to a specific nodeCLUSTER SLAVES node-id List slave nodes of the specified master nodeCLUSTER SLOTS Get array of Cluster slot to node mappingsREADONLY Enables read queries for a connection to a cluster slave nodeREADWRITE Disables read queries for a connection to a cluster slave node