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>,当数据达到限定大小后,会选择配置的策略淘汰数据

猜你喜欢

转载自www.cnblogs.com/BaiLaowu/p/9560509.html
今日推荐