当前位置:网站首页>redis的内存淘汰策略
redis的内存淘汰策略
2022-07-30 06:12:00 【weixin_44953227】
redis的内存淘汰策略
既然可以设置Redis最大占用内存大小,那么配置的内存就有用完的时候。那在内存用完的时候,还继续往Redis里面添加数据不就没内存可用了吗?
实际上Redis定义了几种策略用来处理这种情况:
noeviction(默认策略):对于写请求不再提供服务,直接返回错误(DEL请求和部分特殊请求除外)
allkeys-lru:从所有key中使用LRU算法进行淘汰
volatile-lru:从设置了过期时间的key中使用LRU算法进行淘汰
allkeys-random:从所有key中随机淘汰数据
volatile-random:从设置了过期时间的key中随机淘汰
volatile-ttl:在设置了过期时间的key中,根据key的过期时间进行淘汰,越早过期的越优先被淘汰
#获取当前内存淘汰策略:
127.0.0.1:6379> config get maxmemory-policy
#通过配置文件设置淘汰策略(修改redis.conf文件):
maxmemory-policy allkeys-lru
#通过命令修改淘汰策略:
127.0.0.1:6379> config set maxmemory-policy allkeys-lru
边栏推荐
- New breakthrough in artificial muscle smart materials
- 便携小风扇PD取电芯片
- Map file analysis in Keil software
- golang: Gorm configures Mysql multiple data sources
- Input method for programmers
- 谷粒商城--环境部署(2022/7/28最新)
- 从 Google 离职,前Go 语言负责人跳槽小公司
- 限塑令下的新材料——聚乳酸(PLA)
- Boot process and service control
- SkiaSharp 之 WPF 自绘 拖曳小球(案例版)
猜你喜欢
How does Redis prevent oversold and inventory deduction operations?
MySQL master-slave replication configuration construction, one step in place
How to calculate the daily cumulative capital flow one by one in real time
ARM体系结构概述
2020 ACM | MoFlow: An Invertible Flow Model for Generating Molecular Graphs
01 多线程与高并发 - 基础概念
大飞机C919都用了哪些新材料?
Go uses the mencached cache
export , export default,import完整用法
bean的生命周期
随机推荐
识别“数据陷阱”,发现数据的可疑之处
和AI一起玩儿剧本杀:居然比我还入戏
适合程序员的输入法
分布式锁开发
万能js时间日期格式转换
MySQL basics [naming convention]
C language custom types, rounding
LSF提交作业命令--bsub
go : go-redis list operation
Calculate the inverse source of the matrix (using the adjoint matrix, a 3x3 matrix)
c语言变量的存储方式和生存期 -考察
Vue2进阶篇-编程式路由导航、缓存路由组件、路由的激活与失活
Go uses the mencached cache
go : 使用 grom 删除数据库数据
Keil编译大小和存储说明
DP5340 domestic replacement for CM5340 stereo audio A/D converter chip
入选“十大硬核科技”,详解可信密态计算(TECC)技术点
assert
How to understand plucker coordinates (geometric understanding)
uniapp中canvas与v-if更“配”