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)06/01 Report--
Editor to share with you the reasons why redis can be implemented quickly, I believe most people do not know much about it, so share this article for your reference. I hope you will gain a lot after reading this article. Let's learn about it together.
Redis is single-threaded:
Single threading means that the network request module uses a single thread (so concurrency security is not considered), that is, one thread handles all network requests, while other modules still use multiple threads.
Thread safety
Redis actually adopts the concept of thread closure, enclosing tasks in a single thread, which naturally avoids thread safety problems, but for composite operations that rely on multiple redis operations, locks are still required and may be distributed locks.
The reasons why redis can be executed quickly are:
(1) the vast majority of requests are purely memory operations (very fast)
(2) single thread is adopted to avoid unnecessary context switching and competition conditions.
(3) non-blocking IO-IO multiplexing (what does IO multiplexing mean? )
There are three ways of IO multiplexing: select,poll,epoll. It should be noted that select,poll is thread-safe and epoll is thread-safe.
The internal implementation of redis adopts epoll and adopts the simple event framework implemented by epoll+ itself. Read, write, close, and connection in epoll are all converted into events, and then make use of the multiplexing feature of epoll to never waste any time on io. These three conditions are not independent of each other, especially the first, if the request is time-consuming, you can imagine using single-thread throughput and performance. It should be said that redis chose the right technical solution for a particular scenario.
What are the benefits of using Redis?
Fast, because the data is stored in memory, the advantage similar to HashMap,HashMap is that the time complexity of search and operation is O (1).
Support for rich data types and string,list,set,sorted set,hash
Transactions are supported and operations are atomic. the so-called atomicity is that changes to data are either performed or not performed at all.
Rich features: can be used for caching, messages, set expiration time by key, and will be deleted automatically after expiration
The above are the reasons why redis can be executed quickly. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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.