当前位置:网站首页>Redis expiration strategy and elimination strategy
Redis expiration strategy and elimination strategy
2022-08-09 03:05:00 【Eat well without getting fat】
Redis expiration policy
1) Timed expiration
A timer is set for each created KEY, and when it expires, the KEY is deleted.
Advantages: Periodically delete data, memory friendlyDisadvantage: Takes a lot of CPU to clear data, affects cache response time and throughput2) Lazy Expiration
When accessing the KEY, it is determined whether it has expired, and the data will be cleared when it expires.
Advantage: save CPU resourcesCons: Not memory friendly3) Periodically expires
At regular intervals, the expired keys in the memory are randomly cleared.
It is a compromise between timed expiration and lazy expiration.
Both lazy expiration and periodic expiration are used in Redis.
redis' memory elimination strategy
Pre-redis4.0 elimination strategy
volatile-lru: When the memory is not enough to accommodate newly written data, use the LRU (least recently used) algorithm to eliminate from the key with the expiration time set;allkeys-lru: Use the LRU (least recently used) algorithm to evict all keys when the memory is not enough for newly written data.volatile-random: When the memory is not enough to accommodate the newly written data, the data is randomly eliminated from the key with the expiration time set;allkeys-random: Randomly evict data from all keys when memory is insufficient for newly written data.volatile-ttl: When the memory is not enough to accommodate the newly written data, in the key with the expiration time set, it will be eliminated according to the expiration time, and the earlier expired will be eliminated first;noeviction: The default policy, when the memory is not enough to accommodate the newly written data, the new write operation will report an error.New elimination strategy after redis4.0
volatile-lfu: Added in version 4.0, when the memory is not enough to accommodate newly written data, the LFU algorithm is used to delete keys in expired keys.allkeys-lfu: Added in version 4.0, when the memory is not enough to accommodate newly written data, the LFU algorithm is used to eliminate all keys;边栏推荐
猜你喜欢
随机推荐
【面试整理】-- 多线程
Building PO layered architecture of automated testing framework from 0
原文翻译:Structure Aware Single-stage 3D Object Detection from Point Cloud
MVVM项目开发(商品管理系统二)
渗透测试-域环境下的信息收集
Redis的过期策略和淘汰策略
数学基础(三)PCA原理与推导
[TensorRT] 对UNet进行推理加速
Jenkins configuration nail notification
C18-PEG- ALD批发_C18-PEG-CHO_C18-PEG-醛基
通过kvm创建共享磁盘
Jenkins environment deployment, (packaging, publishing, deployment, automated testing)
leetcode-23.合并K个升序链表
【扫雷--1】
JavsScript系列-Promise的错误捕获
button click animation
SwiftUI * Grid
Shell脚本:正则表达式
20220527动态规划:零钱兑换
Rotate the neon circle







![[TensorRT] 对UNet进行推理加速](/img/38/fa8ce73a5ae7691d416bf9aaadc769.png)

