In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "what is the use of the five data types of Redis". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Redis characteristics
Redis supports data persistence. You can save the data in memory on disk and load it again when you restart it.
Redis not only supports simple key-value type data, but also divides value into data structures such as list,set,zset,hash.
Because Redis exchanges data quickly, it is often used to store some data that needs to be fetched frequently in the server to improve efficiency.
Redis data model
Redis supports five data types: string (string), hash (hash), list (list), set (collection) and zset (sorted set: ordered collection).
Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community
String-> string
Hash-> Hash
List-> list
Set-> Collection
Zset-> ordered set
Basic use of Redis
Connect redis:redis-cli
Exit: exit
Operation server: service redis start/stop/restart
Switch database: select n
The use of the five data types of Redis
1. Commands used by global key operations for all five data types
View all key:keys * delete key-value pairs: del key rename: rename key new_key setting expiration time: expire key seconds
2.String Typ
Strings is the most basic data type of redis. One key corresponds to one value.
Set data: set key value view data: get key append data: append key value delete data: del key
3.List Typ
Add data: rpush key value [value...] Lpush key value [value...] Add data to the header to view data: lrange key start stop lindex key index to view a certain data modify data: lset key index value delete data: rpop key lpop key header delete data
4.Hash Typ
Add data: hset key field value View Domain value: hget key field hgetall key View all field and value View all value:hvals key View all field:hkeys key
5.Set Typ
Add data: sadd key member [member...] View data: smembers key random deletion: spop key specified deletion: srem key member [member …]
6.Sorted Set Typ
Add data: zadd key score member [score2 member2...] View data: zrange key start stop zrangebyscore key min max views deleted data through the score value: zrem key member [member...] Delete multiple data through the index: zremrangebyrank key min max zremrangebyscore key min max-- deleted by the score value
Flushall deletes all data
This is the end of the content of "what is the use of the five data types of Redis". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.