当前位置:网站首页>Redis delete policy
Redis delete policy
2022-07-06 02:26:00 【Flying rookie uncle】
One 、 Deletion policy
1. Expired data
- stay redis Medium , Data with expiration time set
- When a data expires , It will not be deleted from memory immediately
- Data storage form : Maintained a value And the corresponding expiration time
2. Deletion policy
- The deletion strategy refers to targeting expires Operate in the area
- I'm sure it won't happen because of a lot of expire, Crush the server
2.1 Delete regularly
# 1. Realization way
Create a timer , When key When there is an expiration time , Time is up. , The timer task will be executed immediately
take expires Areas and k-v Areas are deleted
# 2. Advantages and disadvantages
advantage : To save memory
shortcoming :cpu pressure , There is no way at this time cpu How high is the load , Will occupy cpu To release , influence redis Throughput
2.2 Lazy deletion
# 1. Realization way
After the data has expired , It's not going to be deleted immediately
Wait until the next time the data is accessed ,redis Will delete the data , And return the value as nil
# 2 Advantages and disadvantages
advantage : save cpu Resources for
shortcoming : There may be a lot of , Unattended data will always be stored on the server
2.3 Delete periodically
# 1. Realization way
Every second, I will check redis Poll the data of each library in
Polled data , Randomly delete some expired data
If the ratio of randomly deleted data to rotation training data exceeds a certain value , Continue polling for deletion
Two 、 Eviction strategy
- If no expiration time is set for all data , Then the data will always be saved
- If too much data is stored , Then there will be redis Out of memory problem
- The eviction strategy is aimed at this problem
- New data enters redis in , If there is not enough memory , Will eject the algorithm many times . If it still fails , Will appear OOM error
1 Detect volatile data
- That is, data that may expire
1. volatile-lru: least recently used: Recently, the least used data has been eliminated
2. volatile-lfu:least frequently used: The data that has been used least recently is eliminated
3. volatile-ttl: Data that is about to expire will be eliminated
4. volatile-random: Randomly selected data
2 Full database data
1. volatile-lru: least recently used: Recently, the least used data has been eliminated
2. volatile-lfu:least frequently used: The data that has been used least recently is eliminated
3. volatile-random: Randomly selected data
3 Abandon data drive
noeviction: Exclusion data , May trigger OOM
The default configuration
4. Configuration mode
- redis.conf Configuration in file
maxmemory-policy noeviction
边栏推荐
- Bigder: I felt good about the 34/100 interview, but I didn't receive the admission
- Is there a case where sqlcdc monitors multiple tables and then associates them to sink to another table? All operations in MySQL
- 【机器人库】 awesome-robotics-libraries
- Derivation of Biot Savart law in College Physics
- [coppeliasim] 6-DOF path planning
- Online reservation system of sports venues based on PHP
- 729. 我的日程安排表 I / 剑指 Offer II 106. 二分图
- Paper notes: limit multi label learning galaxc (temporarily stored, not finished)
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- Text editing VIM operation, file upload
猜你喜欢
论文笔记: 图神经网络 GAT
在线怎么生成富文本
Audio and video engineer YUV and RGB detailed explanation
[solution] add multiple directories in different parts of the same word document
Crawler (9) - scrape framework (1) | scrape asynchronous web crawler framework
Campus second-hand transaction based on wechat applet
【社区人物志】专访马龙伟:轮子不好用,那就自己造!
Sword finger offer 29 Print matrix clockwise
LeetCode 103. Binary tree zigzag level order transverse - Binary Tree Series Question 5
How to improve the level of pinduoduo store? Dianyingtong came to tell you
随机推荐
SSM 程序集
Easy to use js script
一题多解,ASP.NET Core应用启动初始化的N种方案[上篇]
大厂镜像库
Grabbing and sorting out external articles -- status bar [4]
[untitled] a query SQL execution process in the database
Apicloud openframe realizes the transfer and return of parameters to the previous page - basic improvement
Executing two identical SQL statements in the same sqlsession will result in different total numbers
729. 我的日程安排表 I / 剑指 Offer II 106. 二分图
Paper notes: limit multi label learning galaxc (temporarily stored, not finished)
Minecraft 1.18.1、1.18.2模组开发 22.狙击枪(Sniper Rifle)
High number_ Vector algebra_ Unit vector_ Angle between vector and coordinate axis
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
【coppeliasim】6自由度路径规划
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
A basic lintcode MySQL database problem
Lecture 4 of Data Engineering Series: sample engineering of data centric AI
SPI communication protocol
Minecraft 1.18.1, 1.18.2 module development 22 Sniper rifle
I like Takeshi Kitano's words very much: although it's hard, I will still choose that kind of hot life