Redis当内存满后,设置maxmemory-policy执行的key删除策略

redis2.6+版本,redis.conf中的默认的策略是 noeviction ,一共有八种:

# volatile-lru -> Evict using approximated LRU among the keys with an expire set.
# allkeys-lru -> Evict any key using approximated LRU.
# volatile-lfu -> Evict using approximated LFU among the keys with an expire set.
# allkeys-lfu -> Evict any key using approximated LFU.
# volatile-random -> Remove a random key among the ones 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 evict anything, just return an error on write operations.

1、volatile-lru:只对设置了过期时间的key进行LRU算法进行删除
2、allkeys-lru : 对所有key执行LRU算法进行删除
3、volatile-lfu:只对设置了过期时间的key进行LFU算法进行删除
4、allkeys-lfu:对所有key执行LFU算法进行删除
5、volatile-random:随机删除设置有过期时间的key
6、allkeys-random:随机删除
7、volatile-ttl : 删除即将过期的
8、noeviction : 永不过期,返回错误

redis2.6及以前的版本,redis.conf中的默认的策略是 volatile-lru,一共有六种:

# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key accordingly 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

1、volatile-lru:只对设置了过期时间的key进行LRU算法进行删除
2、allkeys-lru : 对所有key执行LRU算法进行删除
3、volatile-random:随机删除设置有过期时间的key
4、allkeys-random:随机删除
5、volatile-ttl : 删除即将过期的
6、noeviction : 永不过期,返回错误

PS:
LRU(least recently used)最近最少使用
LFU(least frequently used )最少经常使用

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值