当前位置:网站首页>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
边栏推荐
- MySQL basics [naming convention]
- mysql高阶语句(一)
- The newcomer deleted data by mistake, and the team leader skillfully used MySQL master-slave replication to delay the recovery of losses
- When does MySQL use table locks and when does it use row locks?
- Boot process and service control
- C语言自定义类型详解
- Monkey and Banana
- 千万级数据量的表,怎样最快速度查询?
- Map file analysis in Keil software
- 分布式锁开发
猜你喜欢

uniapp中canvas与v-if更“配”

What happens when @Bean and @Component are used on the same class?

export , export default,import完整用法

ETL为什么经常变成ELT甚至LET?

Universal js time date format conversion

DNS domain name resolution services

【day5】数组

专访蚂蚁:这群技术排头兵,如何做好底层开发这件事?| 卓越技术团队访谈录

ARM体系结构概述

The introduction of AI meta-learning into neuroscience, the medical effect is expected to improve accurately
随机推荐
interface
SkiaSharp 之 WPF 自绘 拖曳小球(案例版)
sql concat()函数
MySQL master-slave replication configuration construction, one step in place
uniapp中canvas与v-if更“配”
How to understand plucker coordinates (geometric understanding)
Electron之初出茅庐——搭建环境并运行第一个程序
Map file analysis in Keil software
The first artificial intelligence safety competition officially launched
Ali: How many methods are there for multi-threaded sequential operation?
架构设计指南 如何成为架构师
Go 使用 freecache 缓存
使用navicat连接mysql数据库时常报的错误:2003、1698、1251
this与super
五号黯区靶场 mysql 注入之limit注入记录
Monkey and Banana
云服务器零基础部署网站(保姆级教程)
MySql详解基础
bean的生命周期
go : go-redis list操作