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 > Database >
Share
Shulou(Shulou.com)06/01 Report--
What are the application scenarios of Redis in the project? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!
Redis is an open source low-level key-value storage database written in C language. It can be used in scenarios such as caching, event publication subscriptions, high-speed queues, and so on. And support rich data types: string (string), hash (hash), list (list), set (unordered set), zset (sorted set: ordered set)
The Application scenario of Redis in the Project
1. Cache data
Most commonly, it is often called hot data for data that often needs to be queried and does not change very frequently.
2. Message queue
Equivalent to message subscription systems, such as ActiveMQ, RocketMQ. If there are high consistency requirements for data, it is still recommended to use MQ)
3. Counter
For example, counting the click rate and approval rate, redis is atomic and can avoid concurrency problems.
4. E-commerce website information
Large e-commerce platform initializes the cache of page data. For example, when you go to where to buy a ticket, the price of the home page will be different from the price you click in.
5. Hot spot data
For example, real-time hot spots of news websites and hot searches on Weibo, etc., need to be updated frequently. When the total amount of data is relatively large, querying directly from the database will affect performance.
Application scenarios of Redis data types
As mentioned earlier, Redis supports five rich data types, so how do we choose in different scenarios?
1 、 String
Strings are the most commonly used data type, and they can store any type of string, including binary, JSON-based objects, and even base64-encoded images. The maximum capacity of a string in Redis is 512MB, which can be said to be omnipotent.
2 、 Hash
Often used to store structured data, such as the forum system can be used to store users'Id, nicknames, avatars, points and other information. If you need to modify the information in it, you only need to take out the Value through Key to deserialize and modify the value of an item, and then serialize and store it in Redis, which is stored in the Hash structure. Because the Hash structure will compress and store a single Hash element in less than a certain number, it can save a lot of memory. This does not exist in the String structure.
3 、 List
The implementation of List is a two-way linked list, that is, it can support reverse search and traversal, which is more convenient to operate, but it brings some additional memory overhead. Many implementations within Redis, including send buffer queues, also use this data structure. In addition, you can use the lrange command to do Redis-based paging function, excellent performance, good user experience.
4 、 Set
Set external function is similar to list is a list function, the special feature is that set can automatically arrange weight, when you need to store a list of data, but do not want to duplicate data, you can choose to use set.
5 、 Sort Set
It can be sorted by the weight of a condition, such as a data application that can make a ranking by the number of clicks.
Redis features:
1. Redis is a memory-only operation, which needs to be manually persisted to the hard disk when needed.
2. Redis is single-threaded, thus avoiding the operation of frequent context switching in multithreading.
3. The data structure of Redis is simple, and the operation of the data is relatively simple.
4. Different underlying models are used, and the underlying implementation between them and the application protocol for communicating with the client are different. Redis directly builds its own VM mechanism, because the general system calls system functions, it will waste a certain amount of time to move and request.
5. Using the multi-channel Istroke O multiplexing model, non-blocking Ipicuro
Thank you for reading! After reading the above, do you have a general understanding of the application scenarios of Redis in the project? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.
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.