📜  Redis哈希

📅  最后修改于: 2020-12-02 01:04:42             🧑  作者: Mango

Redis哈希

Redis哈希是表示对象的理想数据类型。它们用于在字符串字段和字符串值之间进行映射。在Redis中,每个哈希可以存储多达40亿个字段-值对。

redis 127.0.0.1:6379> HMSET javatpoint名称“所有技术的解决方案”描述“印度增长最快的教程网站”,每天有100万访问者,1000万页面访问量。

OK
redis 127.0.0.1:6379> HGETALL javatpoint
 1) "name"
 2) "A solution to all Technology"
 3) "description"
 4) "India's fastest growing tutorial website"
 5) "daily"
 6) "1"
 7) "million"
 8) "visitors"
 9) "10"
10) "millions"
11) "page"
12) "visit."
redis 127.0.0.1:6379>


在上面的示例中,“ javatpoint”是Redis哈希,其中包含详细信息(名称,描述,100万,10,访问者,页面,访问)等。

Redis哈希命令

Index Command Description
1 HDEL key field2 [field2] It is used to delete one or more hash fields.
2 HEXISTS key field It is used to determine whether a hash field exists or not.
3 HGET key field It is used to get the value of a hash field stored at the specified key.
4 HGETALL key It is used to get all the fields and values stored in a hash at the specified key
5 HINCRBY key field increment It is used to increment the integer value of a hash field by the given number
6 HINCRBYFLOAT key field increment It is used to increment the float value of a hash field by the given amount
7 HKEYS key It is used to get all the fields in a hash
8 HLEN key It is used to get the number of fields in a hash
9 HMGET key field1 [field2] It is used to get the values of all the given hash fields
10 HMSET key field1 value1 [field2 value2 ] It is used to set multiple hash fields to multiple values
11 HSET key field value It is used to set the string value of a hash field
12 HSETNX key field value It is used to set the value of a hash field, only if the field does not exist
13 HVALS key It is used to get all the values in a hash