In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
It is believed that many inexperienced people have no idea about the principle of Redis and the data types of Redis. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
What is Redis? Redis is a high-performance and free key-value database, which can solve the problems of high concurrency, high scalability and big data storage, so Redis is very important to big data. So what data types does Redis have? To put it simply, there are string, hash, list, set and zset. The following editor will analyze these five data types in detail in the future.
1. What is Redis?
Redis is completely open source and free, complies with the BSD protocol, is a high-performance key-value database Redis and other key-value cache products have the following three features:
Redis supports data persistence. Data in memory can be saved on disk and can be loaded and used again when rebooting.
Redis not only supports simple key-value type data, but also provides storage of data structures such as list,set,zset,hash.
Redis supports data backup, that is, data backup in master-slave mode.
2. What are the advantages of Redis?
Extremely high performance-Redis read speed is 110000 times / s, write speed is 81000 times / s; rich data types-Redis supports binary cases of Strings, Lists, Hashes, Sets and Ordered Sets data type operations; atomicity-all operations of Redis are atomic, meaning either successful execution or failure to perform at all. A single operation is atomic. Multiple operations also support transactions, that is, atomicity, wrapped by MULTI and EXEC instructions; other features-Redis also supports publish/subscribe notifications, key expiration, and so on.
3. What are the data types of Redis?
Redis supports data types in 5: string (string), hash (hash), list (list), set (collection), zset (sorted set: ordered collection).
(1) string
String is the most basic data type of redis. One key corresponds to one value. String is binary secure. That is, the string of redis can contain any data. Such as jpg images or serialized objects. The string type is the most basic data type of redis, and the value of the string type can store up to 512 MB.
(2) hash
Redis hash is a collection of key-value pairs. Redis hash is a mapping table for key and value of type string, and hash is particularly suitable for storing objects.
(3) list
The Redis list is a simple list of strings sorted in the order in which they are inserted. We can add elements to the left or right side of the list.
(4) set
The set of redis is an unordered collection of string types. Collections are implemented through hash tables, so the complexity of adding, deleting, and searching is all O (1). There is a difference between set in redis and set in java. Redis's set is a key corresponding to multiple string types of value, and it is also a collection of string types, but unlike redis's list, string collection elements in set cannot be duplicated, but list can.
(5) Zset
Redis zset, like set, is a collection of elements of type string, and the elements within the collection cannot be repeated. The difference is that each element of zset is associated with a score of type double. Redis sorts the members of the collection from small to large by scores. The element of zset is unique, but the score can be repeated. The zset is sorted by the size of the split.
Feature scenario string (string) binary security can contain any data, such as jpg pictures or serialized objects, a key can store a collection of 521M---Hash (hash) key-value pairs, that is, the Map type in the programming language is suitable for storing objects, and can modify only one attribute value store, read, modify user attributes List (list) two-way linked list as fast as update in the database Provides an API for manipulating a segment of elements.
The latest news ranking and other functions (timeline of moments); message queue Set (collection) hash table implementation, elements can not be added repeatedly delete search complexity is O (1); for the collection to find the intersection, union, difference and other operations common friends; use uniqueness to count all independent ip visits to the site When friends are recommended, if the intersection of tag is greater than a certain threshold, you can recommend Zset (ordered set) to add a weight parameter score to the elements in Set. When the elements are sorted according to score and inserted into the collection, the ranking list has been naturally sorted; the message queue with weight.
After reading the above, have you mastered the principle of Redis and what data types are there in Redis? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.