当前位置:网站首页>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
边栏推荐
- 模板_快速排序_双指针
- Formatting occurs twice when vs code is saved
- [solution] every time idea starts, it will build project
- FTP server, ssh server (super brief)
- How to set an alias inside a bash shell script so that is it visible from the outside?
- 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
- PHP campus financial management system for computer graduation design
- 【无标题】数据库中一条查询SQL执行的过程
- Spark accumulator
- Executing two identical SQL statements in the same sqlsession will result in different total numbers
猜你喜欢
零基础自学STM32-复习篇2——使用结构体封装GPIO寄存器
How to generate rich text online
RDD partition rules of spark
零基础自学STM32-野火——GPIO复习篇——使用绝对地址操作GPIO
【clickhouse】ClickHouse Practice in EOI
Virtual machine network, networking settings, interconnection with host computer, network configuration
【MySQL 15】Could not increase number of max_ open_ files to more than 10000 (request: 65535)
2022年版图解网络PDF
爬虫(9) - Scrapy框架(1) | Scrapy 异步网络爬虫框架
论文笔记: 图神经网络 GAT
随机推荐
The intelligent material transmission system of the 6th National Games of the Blue Bridge Cup
Bigder: I felt good about the 34/100 interview, but I didn't receive the admission
机器学习训练与参数优化的一般过程 (讨论)
Reset nodejs of the system
事故指标统计
LeetCode 103. Binary tree zigzag level order transverse - Binary Tree Series Question 5
sql表名作为参数传递
Executing two identical SQL statements in the same sqlsession will result in different total numbers
Computer graduation design PHP college student human resources job recruitment network
[robot library] awesome robots Libraries
3D drawing ()
Computer graduation design PHP part-time recruitment management system for College Students
Data preparation
Use the list component to realize the drop-down list and address list
Template_ Quick sort_ Double pointer
论文笔记: 极限多标签学习 GalaXC (暂存, 还没学完)
Multi function event recorder of the 5th National Games of the Blue Bridge Cup
【coppeliasim】6自由度路径规划
Formatting occurs twice when vs code is saved
一位博士在华为的22年