增加
| 命令 |
解释 |
| EXPIRE key seconds |
设置一个key的过期的秒数 |
| EXPIREAT key timestamp |
设置一个UNIX时间戳的过期时间 |
| PEXPIRE key milliseconds |
设置key的有效时间以毫秒为单位 |
| PEXPIREAT key milliseconds-timestamp |
设置key的到期UNIX时间戳以毫秒为单位 |
删除
| 命令 |
解释 |
| DEL key [key …] |
删除指定的key(一个或多个) |
| DUMP key |
导出key的值 |
| PERSIST key |
移除key的过期时间 |
| FLUSHDB |
删除当前数据库 |
| FLUSHALL |
删除全部数据库 |
查询
| 命令 |
解释 |
| EXISTS key [key …] |
查询一个key是否存在 |
| KEYS pattern |
查找所有匹配给定的模式的键 |
| KEYS * |
查询全部key |
| SELECT index |
切换数据库 |
| PTTL key |
获取key的有效毫秒数 |
| TTL key |
获取key的有效时间(单位:秒) |
| TYPE |
获取key类型 |
修改
| 命令 |
解释 |
| MOVE key db |
移动一个key到另一个数据库 |
| RENAME key newkey |
将一个key重命名 |
| RENAMENX key newkey |
重命名一个key,新的key必须是不存在的key |
其他
http://www.redis.cn/commands.html#generic
help @generic DEL key [key ...] summary: Delete a key since: 1.0.0 DUMP key summary: Return a serialized version of the value stored at the specified key. since: 2.6.0 EXISTS key [key ...] summary: Determine if a key exists since: 1.0.0 EXPIRE key seconds summary: Set a key's time to live in seconds since: 1.0.0 EXPIREAT key timestamp summary: Set the expiration for a key as a UNIX timestamp since: 1.2.0 KEYS pattern summary: Find all keys matching the given pattern since: 1.0.0 MIGRATE host port key| destination-db timeout [COPY] [REPLACE] [KEYS key] summary: Atomically transfer a key from a Redis instance to another one. since: 2.6.0 MOVE key db summary: Move a key to another database since: 1.0.0 OBJECT subcommand [arguments [arguments ...]] summary: Inspect the internals of Redis objects since: 2.2.3 PERSIST key summary: Remove the expiration from a key since: 2.2.0 PEXPIRE key milliseconds summary: Set a key's time to live in milliseconds since: 2.6.0 PEXPIREAT key milliseconds-timestamp summary: Set the expiration for a key as a UNIX timestamp specified in milliseconds since: 2.6.0 PTTL key summary: Get the time to live for a key in milliseconds since: 2.6.0 RANDOMKEY - summary: Return a random key from the keyspace since: 1.0.0 RENAME key newkey summary: Rename a key since: 1.0.0 RENAMENX key newkey summary: Rename a key, only if the new key does not exist since: 1.0.0 RESTORE key ttl serialized-value [REPLACE] summary: Create a key using the provided serialized value, previously obtained using DUMP. since: 2.6.0 SCAN cursor [MATCH pattern] [COUNT count] summary: Incrementally iterate the keys space since: 2.8.0 SORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination] summary: Sort the elements in a list, set or sorted set since: 1.0.0 TTL key summary: Get the time to live for a key since: 1.0.0 TYPE key summary: Determine the type stored at key since: 1.0.0 WAIT numslaves timeout summary: Wait for the synchronous replication of all the write commands sent in the context of the current connection since: 3.0.0