In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Redis how to use the hash type, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
The hash type is particularly suitable for storing objects.
Hset: set hash field to the specified value. If key does not exist, create it first.
127.0.0.1 purl 6379 > hset myhash field hello
(integer) 1
127.0.0.1 purl 6379 > hget myhash field
"hello"
Hsetnx: set hash field to the specified value, create it first if key does not exist, and return 0 if it exists.
127.0.0.1 purl 6379 > hsetnx myhash field hello
(integer) 0
127.0.0.1 purl 6379 > hsetnx myhash field2 world
(integer) 1
127.0.0.1 purl 6379 > hget myhash field
"hello"
127.0.0.1 purl 6379 > hget myhash field2
"world"
Hmset: set multiple field of hash at the same time.
127.0.0.1 purl 6379 > hmset myhash field1 hello field2 world
OK
Hmget: gets all the specified hash field.
127.0.0.1 purl 6379 > hmget myhash field1 field2
1) "hello"
2) "world"
Hincrby: the specified hash field plus the given value.
127.0.0.1 6379 > hset myhash age 10
(integer) 1
127.0.0.1 purl 6379 > hget myhash age
"10"
127.0.0.1 6379 > hincrby myhash age 8
(integer) 18
127.0.0.1 purl 6379 > hget myhash age
"18"
Hexists: tests whether the specified field exists.
127.0.0.1 purl 6379 > hexists myhash age
(integer) 1
Hlen: returns the number of field of the specified hash.
127.0.0.1 purl 6379 > hlen myhash
(integer) 4
Hdel: deletes the field of the specified hash.
127.0.0.1 purl 6379 > hdel myhash age
(integer) 1
127.0.0.1 purl 6379 > hlen myhash
(integer) 3
Hkeys: returns all field of hash.
127.0.0.1 purl 6379 > hkeys myhash
1) "field"
2) "field2"
3) "field1"
Hvals: returns all value of hash.
127.0.0.1 purl 6379 > hvals myhash
1) "hello"
2) "world"
3) "hello"
Hgetall: get all the field and value in a hash.
127.0.0.1 purl 6379 > hgetall myhash
1) "field"
2) "hello"
3) "field2"
4) "world"
5) "field1"
6) "hello"
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.