当前位置:网站首页>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
边栏推荐
- [robot library] awesome robots Libraries
- Jisuanke - t2063_ Missile interception
- Sword finger offer 29 Print matrix clockwise
- 剑指 Offer 30. 包含min函数的栈
- Minecraft 1.18.1, 1.18.2 module development 22 Sniper rifle
- 更换gcc版本后,编译出现make[1]: cc: Command not found
- 【机器人库】 awesome-robotics-libraries
- UE4 - how to make a simple TPS role (I) - create a basic role
- 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] efficient conveyor belt
猜你喜欢

Use image components to slide through photo albums and mobile phone photo album pages

Httprunnermanager installation (III) - configuring myql Database & initialization data under Linux

Shell脚本更新存储过程到数据库

【机器人库】 awesome-robotics-libraries

A doctor's 22 years in Huawei

Multi function event recorder of the 5th National Games of the Blue Bridge Cup

Online reservation system of sports venues based on PHP

【MySQL 15】Could not increase number of max_ open_ files to more than 10000 (request: 65535)

Structural theme model (I) STM package workflow
![[community personas] exclusive interview with Ma Longwei: the wheel is not easy to use, so make it yourself!](/img/aa/af98b588efd61d71b1b02609817c49.png)
[community personas] exclusive interview with Ma Longwei: the wheel is not easy to use, so make it yourself!
随机推荐
RDD creation method of spark
MySQL learning notes - subquery exercise
Bigder: I felt good about the 34/100 interview, but I didn't receive the admission
【clickhouse】ClickHouse Practice in EOI
Xshell 7 Student Edition
【MySQL 15】Could not increase number of max_open_files to more than 10000 (request: 65535)
PHP campus financial management system for computer graduation design
Have a look at this generation
MySQL (IV) - transactions
Campus second-hand transaction based on wechat applet
How to generate rich text online
How to check the lock information in gbase 8C database?
PHP campus movie website system for computer graduation design
Concept of storage engine
inherited constructors
UE4 - how to make a simple TPS role (I) - create a basic role
A basic lintcode MySQL database problem
[solution] every time idea starts, it will build project
ftp上传文件时出现 550 Permission denied,不是用户权限问题
零基础自学STM32-野火——GPIO复习篇——使用绝对地址操作GPIO