当前位置:网站首页>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 throughput
2) 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 friendly
3) 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;
边栏推荐
- 书签收藏难整理?这款书签工具管理超方便
- 基于NLP的智能问答系统核心技术
- 多商户商城系统功能拆解23讲-平台端分销等级
- 通过kvm创建共享磁盘
- 【21天学习挑战赛】二分查找题目之寻找峰值
- Kubernetes:(十四)安全机制(一定要做好安全措施哦)
- What are the most popular automated testing tools in 2022?The most complete and most detailed of the entire network is here
- 作为常用的荧光标记试剂Cy5 亚磷酰胺(CAS号:182873-67-2)有哪些特点了?
- SwiftUI * SwiftUI 4.0 全新的导航系统
- 【扫雷--2】
猜你喜欢
随机推荐
2022-08-08 第五小组 顾祥全 学习笔记 day31-集合-IO流-File类
redis集群详解
网路编程_socket返回值
flatMap() :对每个元素执行映射函数并将结果展平
【物理应用】基于El-centro地震波作用下隔震与非隔震支座下的顶层位移、速度、加速度的对比情况附matlab代码
ros入门(安装)
Linux安装Redis
MES对接Simba实现展讯平台 IMEI 写号与耦合测试
jsx定义与规则
Financial Industry Software Testing Interview Questions (with Answers) | Getting Started Guide
马斯克被因狗狗币被索赔2580亿美元 操纵价格牟利?狗狗币已下跌92%
全文翻译:Multimodal Neural Networks: RGB-D for Segmantic Segmentation and Object Detection
渗透测试-域环境下的信息收集
【扫雷--1】
[TensorRT] 对UNet进行推理加速
【Untitled】
权限系统就该这么设计(万能通用),稳的一批!
Solve the Final Fantasy 13-2 Clock Puzzle with DFS
关于eBPF与可观测性,你想知道的都在这里
ARM开发(二)ARM体系结构——ARM,数据和指令类型,处理器工作模式,寄存器,状态寄存器,流水线,指令集,汇编小练习题