当前位置:网站首页>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;
边栏推荐
- Working subtotal rtcp length and network byte order
- 基于NLP的智能问答系统核心技术
- Redis的过期策略和淘汰策略
- 全文翻译:Multimodal Neural Networks: RGB-D for Segmantic Segmentation and Object Detection
- 【机器学习】21天挑战赛学习笔记(三)
- 20220528动态规划:最长递增子序列
- 1.02亿美元从数字资产基金撤出!BTC价格已经触底!预示下跌趋势即将逆转?
- Chapter 2数据分析
- Building PO layered architecture of automated testing framework from 0
- flat() :递归地将数组展平到指定的深度
猜你喜欢
甲乙丙丁加工零件,加工的总数是370, 如果甲加工的零件数多10,如果乙加工的零件数少20,如果丙加工的 零件数乘以2,如果丁加工的零件数除以2,四个人的加工数量相等,求甲乙丙丁各自加工多少个零件?
Building PO layered architecture of automated testing framework from 0
JS 运行机制最全面的一次梳理
Kubernetes:(十三)secret与configmap的那些事
作为常用的荧光标记试剂Cy5 亚磷酰胺(CAS号:182873-67-2)有哪些特点了?
二分搜索法和二叉搜索树
redis集群详解
下秒数据CEO蔡致暖受邀参加联合数据举办《数据要素加速跑》线上沙龙
[Redis] The core principle of master-slave replication
Take you do interface test from zero to the first case summary
随机推荐
ARM开发(二)ARM体系结构——ARM,数据和指令类型,处理器工作模式,寄存器,状态寄存器,流水线,指令集,汇编小练习题
2022微服务面试题 最新50道题(含答案解析)
What are the most popular automated testing tools in 2022?The most complete and most detailed of the entire network is here
一款免费的强大办公工具。
二分搜索法和二叉搜索树
C专家编程 第10章 再论指针 10.1 多维数组的内存布局
权限系统就该这么设计(万能通用),稳的一批!
lvs+keepalived高可用负载均衡集群
Leetcode刷题——148. 排序链表
【扫雷--2】
C专家编程 第9章 再论数组 9.2 为什么会发生混淆
【21天学习挑战赛】二分查找题目之寻找峰值
交换VLAN实验
powershell 执行策略
一本通1258——数字金字塔(动态规划)
Kubernetes:(十三)secret与configmap的那些事
C专家编程 第9章 再论数组 9.7 轻松一下---软件/硬件平衡
jsx定义与规则
作为常用的荧光标记试剂Cy5 亚磷酰胺(CAS号:182873-67-2)有哪些特点了?
Take you do interface test from zero to the first case summary