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--
Although the key is set to expire, how do you handle it when it expires? There are usually three rules:
Timed deletion: after the expiration time of the key is set, a timer is started and the key is deleted when the timer of the key expires.
Lazy deletion: no timer is created, and the expiration is not processed. When the key is read again, determine whether it expires. If it expires, delete it and return null. If it does not expire, return the value.
Periodically delete: this is easy to understand, clean once after a period of time, as to whether to clear it all is not necessarily, because if there are too many keys, the overall clean-up will definitely consume a lot of CPU time, so regular cleaning may be to regularly remove some of it, and then complete the overall clean-up in an overall periodic cleaning cycle.
Policy advantages and disadvantages regular deletion is the most effective for memory space, frequent deletion of expired data does not store any expired data will take more CPU time lazy deletion does not take up too much CPU time database will have a large number of expired data, take up memory space to absorb the advantages of timing and lazy deletion, it is necessary to design a good deletion operation duration and execution frequency
Redis uses two strategies: lazy deletion and periodic deletion. In other words, it periodically deletes expired keys, but does not traverse all keys at once, but periodically traverses some of them, traversing all in a long period. In the period of time when regular deletion has not yet been reached, lazy deletion is used, those that have expired are deleted, and those that are not encountered are retained, leaving them for regular deletion processing. Through this mechanism, a balance is found between memory and CPU.
The default period for periodic delete operations is 100ms, which is performed by the serverCron cycle operation function. But how long each delete operation has been executed and how many databases are traversed is determined by the specific algorithm.
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.