增加

命令 解释
SET key value 设置指定 key 的值
MGET key1 [key2..] 获取所有(一个或多个)给定 key 的值
MSETNX key value [key value …] 同时设置一个或多个 key-value 对,当且仅当所有给定 key 都不存在
SETNX key value 只有在 key 不存在时设置 key 的值

删除

命令 解释
FLUSHDB 清空当前数据库
FLUSHALL 清空所有数据库

查询

命令 解释
KEY * 查询所有key
GET key 获取指定 key 的值
GETRANGE key start end 返回 key 中字符串值的子字符
GETSET key value 将给定 key 的值设为 value ,并返回 key 的旧值(old value)
STRLEN key 返回 key 所储存的字符串值的长度

修改

命令 解释
SETEX key seconds value 将值 value 关联到 key ,并将 key 的过期时间设为 seconds (以秒为单位)。
PSETEX key milliseconds value 这个命令和 SETEX 命令相似,但它以毫秒为单位设置 key 的生存时间,而不是像 SETEX 命令那样,以秒为单位
SETRANGE key offset value 从偏移量开始赋值
INCR key 将 key 中储存的数字值增一
INCRBY key increment 将 key 所储存的值加上给定的增量值(increment)
INCRBYFLOAT key increment 将 key 所储存的值加上给定的浮点增量值(increment)
DECR key 将 key 中储存的数字值减一
DECRBY key decrement key 所储存的值减去给定的减量值(decrement)
APPEND key value 如果 key 已经存在并且是一个字符串, APPEND 命令将指定的 value 追加到该 key 原来值(value)的末尾

其他

http://www.redis.cn/commands.html#string

  1. help @string
  2. APPEND key value
  3. summary: Append a value to a key
  4. since: 2.0.0
  5. BITCOUNT key [start end]
  6. summary: Count set bits in a string
  7. since: 2.6.0
  8. BITFIELD key [GET type offset] [SET type offset value] [INCRBY type offset increment] [OVERFLOW WRAP|SAT|FAIL]
  9. summary: Perform arbitrary bitfield integer operations on strings
  10. since: 3.2.0
  11. BITOP operation destkey key [key ...]
  12. summary: Perform bitwise operations between strings
  13. since: 2.6.0
  14. BITPOS key bit [start] [end]
  15. summary: Find first bit set or clear in a string
  16. since: 2.8.7
  17. DECR key
  18. summary: Decrement the integer value of a key by one
  19. since: 1.0.0
  20. DECRBY key decrement
  21. summary: Decrement the integer value of a key by the given number
  22. since: 1.0.0
  23. GET key
  24. summary: Get the value of a key
  25. since: 1.0.0
  26. GETBIT key offset
  27. summary: Returns the bit value at offset in the string value stored at key
  28. since: 2.2.0
  29. GETRANGE key start end
  30. summary: Get a substring of the string stored at a key
  31. since: 2.4.0
  32. GETSET key value
  33. summary: Set the string value of a key and return its old value
  34. since: 1.0.0
  35. INCR key
  36. summary: Increment the integer value of a key by one
  37. since: 1.0.0
  38. INCRBY key increment
  39. summary: Increment the integer value of a key by the given amount
  40. since: 1.0.0
  41. INCRBYFLOAT key increment
  42. summary: Increment the float value of a key by the given amount
  43. since: 2.6.0
  44. MGET key [key ...]
  45. summary: Get the values of all the given keys
  46. since: 1.0.0
  47. MSET key value [key value ...]
  48. summary: Set multiple keys to multiple values
  49. since: 1.0.1
  50. MSETNX key value [key value ...]
  51. summary: Set multiple keys to multiple values, only if none of the keys exist
  52. since: 1.0.1
  53. PSETEX key milliseconds value
  54. summary: Set the value and expiration in milliseconds of a key
  55. since: 2.6.0
  56. SET key value [EX seconds] [PX milliseconds] [NX|XX]
  57. summary: Set the string value of a key
  58. since: 1.0.0
  59. SETBIT key offset value
  60. summary: Sets or clears the bit at offset in the string value stored at key
  61. since: 2.2.0
  62. SETEX key seconds value
  63. summary: Set the value and expiration of a key
  64. since: 2.0.0
  65. SETNX key value
  66. summary: Set the value of a key, only if the key does not exist
  67. since: 1.0.0
  68. SETRANGE key offset value
  69. summary: Overwrite part of a string at key starting at the specified offset
  70. since: 2.2.0
  71. STRLEN key
  72. summary: Get the length of the value stored in a key
  73. since: 2.2.0