简介

  • Redis Hash(哈希)
  • 命令特征:所有命令开始前都带有字母“H”

    增加

    | 命令 | 解释 | | —- | —- | | HMSET key field value [field value …] | 设置hash字段值 | | HSET key field value | 设置hash里面一个字段的值 | | HSETNX key field value | 设置hash的一个字段,只有当这个字段不存在时有效 | | HINCRBY key field increment | 将hash中指定域的值增加给定的数字 | | HINCRBYFLOAT key field increment | 将hash中指定域的值增加给定的浮点数 |

删除

命令 解释
HDEL key field [field …] 删除一个或多个Hash的field

查询

命令 解释
HVALS key 获得hash的所有值
HSTRLEN key field 获取hash里面指定field的长度
HGET key field 获取hash中field的值
HEXISTS key field 判断field是否存在于hash中
HGETALL key 从hash中读取全部的域和值
HKEYS key 获取hash的所有字段
HLEN key 获取hash里所有字段的数量
HMGET key field [field …] 获取hash里面指定字段的值

修改

命令 解释
HSCAN key cursor [MATCH pattern] [COUNT count] 迭代hash里面的元素

其他

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

  1. help @hash
  2. HDEL key field [field ...]
  3. summary: Delete one or more hash fields
  4. since: 2.0.0
  5. HEXISTS key field
  6. summary: Determine if a hash field exists
  7. since: 2.0.0
  8. HGET key field
  9. summary: Get the value of a hash field
  10. since: 2.0.0
  11. HGETALL key
  12. summary: Get all the fields and values in a hash
  13. since: 2.0.0
  14. HINCRBY key field increment
  15. summary: Increment the integer value of a hash field by the given number
  16. since: 2.0.0
  17. HINCRBYFLOAT key field increment
  18. summary: Increment the float value of a hash field by the given amount
  19. since: 2.6.0
  20. HKEYS key
  21. summary: Get all the fields in a hash
  22. since: 2.0.0
  23. HLEN key
  24. summary: Get the number of fields in a hash
  25. since: 2.0.0
  26. HMGET key field [field ...]
  27. summary: Get the values of all the given hash fields
  28. since: 2.0.0
  29. HMSET key field value [field value ...]
  30. summary: Set multiple hash fields to multiple values
  31. since: 2.0.0
  32. HSCAN key cursor [MATCH pattern] [COUNT count]
  33. summary: Incrementally iterate hash fields and associated values
  34. since: 2.8.0
  35. HSET key field value
  36. summary: Set the string value of a hash field
  37. since: 2.0.0
  38. HSETNX key field value
  39. summary: Set the value of a hash field, only if the field does not exist
  40. since: 2.0.0
  41. HSTRLEN key field
  42. summary: Get the length of the value of a hash field
  43. since: 3.2.0
  44. HVALS key
  45. summary: Get all the values in a hash
  46. since: 2.0.0