简介
- 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
help @hash HDEL key field [field ...] summary: Delete one or more hash fields since: 2.0.0 HEXISTS key field summary: Determine if a hash field exists since: 2.0.0 HGET key field summary: Get the value of a hash field since: 2.0.0 HGETALL key summary: Get all the fields and values in a hash since: 2.0.0 HINCRBY key field increment summary: Increment the integer value of a hash field by the given number since: 2.0.0 HINCRBYFLOAT key field increment summary: Increment the float value of a hash field by the given amount since: 2.6.0 HKEYS key summary: Get all the fields in a hash since: 2.0.0 HLEN key summary: Get the number of fields in a hash since: 2.0.0 HMGET key field [field ...] summary: Get the values of all the given hash fields since: 2.0.0 HMSET key field value [field value ...] summary: Set multiple hash fields to multiple values since: 2.0.0 HSCAN key cursor [MATCH pattern] [COUNT count] summary: Incrementally iterate hash fields and associated values since: 2.8.0 HSET key field value summary: Set the string value of a hash field since: 2.0.0 HSETNX key field value summary: Set the value of a hash field, only if the field does not exist since: 2.0.0 HSTRLEN key field summary: Get the length of the value of a hash field since: 3.2.0 HVALS key summary: Get all the values in a hash since: 2.0.0