📅  最后修改于: 2020-11-26 07:02:36             🧑  作者: Mango
Redis哈希是字符串字段和字符串值之间的映射。因此,它们是代表对象的理想数据类型。
在Redis中,每个哈希可以存储多达40亿个字段-值对。
redis 127.0.0.1:6379> HMSET tutorialspoint name "redis tutorial"
description "redis basic commands for caching" likes 20 visitors 23000
OK
redis 127.0.0.1:6379> HGETALL tutorialspoint
1) "name"
2) "redis tutorial"
3) "description"
4) "redis basic commands for caching"
5) "likes"
6) "20"
7) "visitors"
8) "23000"
在上面的示例中,我们在名为“ tutorialspoint”的哈希中设置了Redis教程详细信息(名称,描述,喜欢,访问者)。
下表列出了一些与哈希相关的基本命令。
Sr.No | Command & Description |
---|---|
1 | HDEL key field2 [field2]
Deletes one or more hash fields. |
2 | HEXISTS key field
Determines whether a hash field exists or not. |
3 | HGET key field
Gets the value of a hash field stored at the specified key. |
4 | HGETALL key
Gets all the fields and values stored in a hash at the specified key |
5 | HINCRBY key field increment
Increments the integer value of a hash field by the given number |
6 | HINCRBYFLOAT key field increment
Increments the float value of a hash field by the given amount |
7 | HKEYS key
Gets all the fields in a hash |
8 | HLEN key
Gets the number of fields in a hash |
9 | HMGET key field1 [field2]
Gets the values of all the given hash fields |
10 | HMSET key field1 value1 [field2 value2 ]
Sets multiple hash fields to multiple values |
11 | HSET key field value
Sets the string value of a hash field |
12 | HSETNX key field value
Sets the value of a hash field, only if the field does not exist |
13 | HVALS key
Gets all the values in a hash |
14 | HSCAN key cursor [MATCH pattern] [COUNT count]
Incrementally iterates hash fields and associated values |