redis 数据淘汰策略与配置


redis 数据淘汰策略

volatile-lru:从已设置过期的数据集中挑选最近最少使用的淘汰
volatile-ttr:从已设置过期的数据集中挑选将要过期的数据淘汰
volatile-random:从已设置过期的数据集中任意挑选数据淘汰
allkeys-lru:从数据集中挑选最近最少使用的数据淘汰
allkeys-random:从数据集中任意挑选数据淘汰
noenviction:禁止淘汰数据
redis淘汰数据时还会同步到aof中、从机


配置文件 

# maxmemory <bytes>
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key according to the LRU algorithm
# volatile-random -> remove a random key with an expire set
# allkeys-random -> remove a random key, any key
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
# noeviction -> don't expire at all, just return an error on write operations
# The default is:
# maxmemory-policy noeviction
我们可以设置maxmemory <bytes>,当数据达到限定大小后,会选择配置的策略淘汰数据


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM