增加

命令 解释
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

  1. help @generic
  2. DEL key [key ...]
  3. summary: Delete a key
  4. since: 1.0.0
  5. DUMP key
  6. summary: Return a serialized version of the value stored at the specified key.
  7. since: 2.6.0
  8. EXISTS key [key ...]
  9. summary: Determine if a key exists
  10. since: 1.0.0
  11. EXPIRE key seconds
  12. summary: Set a key's time to live in seconds
  13. since: 1.0.0
  14. EXPIREAT key timestamp
  15. summary: Set the expiration for a key as a UNIX timestamp
  16. since: 1.2.0
  17. KEYS pattern
  18. summary: Find all keys matching the given pattern
  19. since: 1.0.0
  20. MIGRATE host port key| destination-db timeout [COPY] [REPLACE] [KEYS key]
  21. summary: Atomically transfer a key from a Redis instance to another one.
  22. since: 2.6.0
  23. MOVE key db
  24. summary: Move a key to another database
  25. since: 1.0.0
  26. OBJECT subcommand [arguments [arguments ...]]
  27. summary: Inspect the internals of Redis objects
  28. since: 2.2.3
  29. PERSIST key
  30. summary: Remove the expiration from a key
  31. since: 2.2.0
  32. PEXPIRE key milliseconds
  33. summary: Set a key's time to live in milliseconds
  34. since: 2.6.0
  35. PEXPIREAT key milliseconds-timestamp
  36. summary: Set the expiration for a key as a UNIX timestamp specified in milliseconds
  37. since: 2.6.0
  38. PTTL key
  39. summary: Get the time to live for a key in milliseconds
  40. since: 2.6.0
  41. RANDOMKEY -
  42. summary: Return a random key from the keyspace
  43. since: 1.0.0
  44. RENAME key newkey
  45. summary: Rename a key
  46. since: 1.0.0
  47. RENAMENX key newkey
  48. summary: Rename a key, only if the new key does not exist
  49. since: 1.0.0
  50. RESTORE key ttl serialized-value [REPLACE]
  51. summary: Create a key using the provided serialized value, previously obtained using DUMP.
  52. since: 2.6.0
  53. SCAN cursor [MATCH pattern] [COUNT count]
  54. summary: Incrementally iterate the keys space
  55. since: 2.8.0
  56. SORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]
  57. summary: Sort the elements in a list, set or sorted set
  58. since: 1.0.0
  59. TTL key
  60. summary: Get the time to live for a key
  61. since: 1.0.0
  62. TYPE key
  63. summary: Determine the type stored at key
  64. since: 1.0.0
  65. WAIT numslaves timeout
  66. summary: Wait for the synchronous replication of all the write commands sent in the context of the current connection
  67. since: 3.0.0