In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use Redis hash. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Redis hash (Hash)
The KV mode remains the same, but V is a key-value pair
1.hset/hget/hmset/hgetall/hdel
Hset: addin
Hget: get
Hmset: adding in batch
Hgetall: get all the key-value information in key
Hdel: delete an attribute in key
127.0.0.1 hset user id 9736 > hget user sex 11 (integer) 1127.0.0.1 hget user id 9736 > hset user name blue sex man (integer) 2127.0.1 name li4 age 9736 > hget user name sex (error) ERR wrong number of arguments for 'hget' command127.0.0.1:9736 > hget user name "blue" 127.0.1 > hget user sex "man" 127.0.0.1 > hmset customer id 11 name li4 age 26OK127.0.0.1:9736 > hmget customer id name age1) "11" 2) "li4" 3) "26" 127.0.0.1 li4 9736 > HGETALL customer 1) "id" 2) "11" 3) "name" 4) "li4" 5) "age" 6) "26" 127.0.1) 9736 > hdel user sex (integer) 1127.0.0.1) 9736 > HGETALL user1) "id" 2) "11" 3) "4)" blue "2. Hlen gets the number of key-value pairs 127.0.0.1 HLEN user 9736 > HLEN user (integer) 2127.0.1 integer 9736 > HLEN customer (integer) 33.hexists key a value in the key key127.0.0.1:9736 > HGETALL user1)" id "2)" 11 "3)" name "4)" blue "127.0.0.1 HLEN user 9736 > hgetall customer1)" id "2)" 11 "3)" name " 4) "li4" 5) "age" 127.0.0.1 integer 9736 > HEXISTS user id (integer) 1127.0.1 VR 9736 > HEXISTS customer age (integer) 14.hkeys / hvals key list List of values 127.0.0.1 HKEYS customer1 9736) "id" 2) "name" 3) "age" 127.0.0.1 name 9736 > HVALS customer1) "11" 2) "li4" 3) "26" 5.hincrby/hincrbyfloat increments 127.0.0.1 age 9736 > HGETALL customer1) "id" 2) "11" 3) "name" 4) "li4" 5) "age" 6) "36" 127.0.0. 1id 9736 > HINCRBYfloat customer age 0.1 "36.1" 127.0.0.1 HGETALL customer 0.4 "36.5" 127.0.1 HGETALL customer 1) "id" 2) "11" 3) "name" 4) "li4" 5) "age" 6) "36.5" 6.hsetnx
Add key value if it does not exist, otherwise do not add
127.0.0.1 HSETNX customer email 9736 > HGETALL customer1) 1127.0.0.1 name 9736 > HGETALL customer1) "id" 2) "11" 3) "name" 4) "li4" 5) "age" 6) "36.5" 7) "email" 8) Thank you for reading! This is the end of the article on "how to use Redis hash". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.