当前位置:网站首页>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详解基础
Basic usage of tree arrays
Playing script killing with AI: actually more involved than me
[GO Language Basics] 1. Why do I want to learn Golang and get started with GO language
Architectural Design Guide How to Become an Architect
树状数组的基本用法
Go uses the mencached cache
Get all interface paths and names in the controller
What happens when @Bean and @Component are used on the same class?
架构设计指南 如何成为架构师
随机推荐
c语言变量的存储方式和生存期 -考察
Universal js time date format conversion
包含min函数的栈(js)
assert
Go uses freecache for caching
go : use gorm to modify data
When does MySQL use table locks and when does it use row locks?
Input method for programmers
Max Sum Plus Plus HDU - 1024
IDEA 中CheckStyle安装及使用
MySql详解基础
分布式锁开发
export , export default,import完整用法
[GO语言基础] 一.为什么我要学习Golang以及GO语言入门普及
taro 打包编译报错
Develop common tool software
go : 使用gorm修改数据
DP5340国产替代CM5340立体声音频A/D转换器芯片
go : go-redis set operations
go : create database records using gorm