在redis中,如果设置的maxmemory,那就要配置key的回收机制参数maxmemory-policy,默认volatile-lru,参阅redis作者的原博客:
原文中写得很清楚:
another way to use redis as a cache is the maxmemory directive, a feature that allows specifying a maximum amount of memory to use. when new data is added to the server, and the memory limit was already reached, the server will remove some old data deleting a volatile key, that is, a key with an expire (a timeout) set, even if the key is still far from expiring automatically.
在redis服务器占用内存达到maxmemory的情况下,当再想增加内存占用时,会按maxmemory-policy机制将老的数据删除。这里简单说一下volatile-lru,redis会按lru算法删除设置了过期时间但还没有过期的key,而对于没有设置过期时间的key,redis是永远保留的。当然,如果你不想删除没有过期的key,那可以使用noeviction机制
# maxmemory policy: how redis will select what to remove when maxmemory
# is reached? you can select among five behavior:
#
# 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、 性能(1) 前端性能优化主要方式:浏览器缓存、CDN加速、反向代理(2) 应用服务器性能优化主要方式:代码...
[阅读全文]
-
-
第一次作业
1、简述redis应用场景(1)高性能适合当做缓存(2)单线程可以作为分布式锁(3)自动过期能有效提升开发效率(...
[阅读全文]
-
-
-
-
-
07.21
1.mongodb内嵌查询。2.redis aof和rdb。3.记录一天下单量(锁和channel选用)。4.g...
[阅读全文]
-
Redis主从模式
Redis有三种集群模式:主从模式、Sentinel模式、Cluster模式主从模式Sentinel模式Clus...
[阅读全文]
-
Zabbix监控
#### 1.zabbix监控日志文件配置[root@localhost ~]# mkdir /scripts/...
[阅读全文]
网友评论