一、键操作(keys)
DEL key [key ...] 删除一个key DUMP 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 返回一个随机的key RENAME key newkey 将一个key重命名 RENAMENX key newkey 重命名一个key,新的key必须是不存在的key RESTORE 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 connection SCAN 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 details COMMAND COUNT Get total number of Redis commands COMMAND GETKEYS Extract keys given a full Redis command COMMAND INFO command-name [command-name ...] Get array of specific Redis command details CONFIG 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 replication SAVE 同步数据到磁盘上 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 strings BITPOS key bit [start] [end] Find first bit set or clear in a string DECR key 整数原子减1 DECRBY key decrement 原子减指定的整数 GET key 返回key的value GETBIT 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 value MSETNX key value [key value ...] 设置多个key value,仅当key存在时 PSETEX key milliseconds value Set the value and expiration in milliseconds of a key SET 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 key SETEX key seconds value 设置key-value并设置过期时间(单位:秒) SETNX key value 设置的一个关键的价值,只有当该键不存在 SETRANGE key offset value Overwrite part of a string at key starting at the specified offset STRLEN key 获取指定key值的长度
四、集群操作(cluster)
CLUSTER ADDSLOTS slot [slot ...] Assign new hash slots to receiving node CLUSTER COUNT-FAILURE-REPORTS node-id Return the number of failure reports active for a given node CLUSTER COUNTKEYSINSLOT slot Return the number of local keys in the specified hash slot CLUSTER DELSLOTS slot [slot ...] Set hash slots as unbound in receiving node CLUSTER FAILOVER [FORCE|TAKEOVER] Forces a slave to perform a manual failover of its master. CLUSTER FORGET node-id Remove a node from the nodes table CLUSTER GETKEYSINSLOT slot count Return local key names in the specified hash slot CLUSTER INFO Provides info about Redis Cluster node state CLUSTER KEYSLOT key Returns the hash slot of the specified key CLUSTER MEET ip port Force a node cluster to handshake with another node CLUSTER NODES Get Cluster config for the node CLUSTER REPLICATE node-id Reconfigure a node as a slave of the specified master node CLUSTER RESET [HARD|SOFT] Reset a Redis Cluster node CLUSTER SAVECONFIG Forces the node to save cluster state on disk CLUSTER SET-CONFIG-EPOCH config-epoch Set the configuration epoch in a new node CLUSTER SETSLOT slot IMPORTING|MIGRATING|STABLE|NODE [node-id] Bind an hash slot to a specific node CLUSTER SLAVES node-id List slave nodes of the specified master node CLUSTER SLOTS Get array of Cluster slot to node mappings READONLY Enables read queries for a connection to a cluster slave node READWRITE Disables read queries for a connection to a cluster slave node
原文地址:http://oldcat1981.blog.51cto.com/10670523/1775385