In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail about the memory elimination mechanism in redis. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Redis memory obsolescence means that some keys stored by the user can be actively deleted by Redis from the instance, resulting in reading miss, so why should Redis have this function? This is the original intention of the design that we need to explore. The two most common Redis application scenarios are caching and persistent storage. The first question to be clear is which scenario is the memory obsolescence strategy more appropriate? Is it persistent or cached?
The original intention of the memory elimination mechanism is to make better use of memory, using a certain cache miss in exchange for memory efficiency.
Redis memory obsolescence mechanisms include:
1. Noeviction, when the memory usage reaches the threshold, all commands that cause applications for memory will report an error.
2. Allkeys-lru. In the primary key space, remove the recently unused key first.
3. Allkeys-random, which is randomly removed in the primary key space.
Memory elimination strategy
Memory elimination is only a function provided by Redis. In order to better achieve this function, different strategies must be provided for different application scenarios. Memory elimination strategy is about what we should do to achieve memory elimination. The problems to be solved include how to choose the elimination key space. How to choose the elimination key in the key space?
Redis provides the following elimination policies for users to choose from, of which the default policy is noeviction policy:
Noeviction: when memory usage reaches the threshold, all commands that cause requests for memory will report an error
Allkeys-lru: in the primary key space, remove the recently unused ones first
Keyvolatile-lru: in the key space where the expiration time is set, remove the recently unused ones first
Keyallkeys-random: in the primary key space, randomly remove a
Keyvolatile-random: in the key space where the expiration time is set, randomly remove a
Keyvolatile-ttl: in the key space where the expiration time is set, the key with earlier expiration time is removed first
Here to add the primary key space and set the expiration time of the key space, for example, suppose we have a batch of keys stored in Redis, then there is a hash table to store these keys and their values, if part of this batch of keys set the expiration time, then this batch of keys will also be stored in another hash table, the value in this hash table corresponds to the expiration time when the key is set. The key space with the expiration time set is a subset of the primary key space.
On the memory elimination mechanism in redis to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.