原文:Redis的LRU机制

在Redis中,如果设置的maxmemory,那就要配置key的回收机制参数maxmemory-policy,默认volatile-lru,参阅Redis作者的原博客:antirez weblog >> Redis as an LRU cache

原文中写得很清楚:

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. 视频 - 在 VirtualBox 中部署 OpenStack
  2. svn检出项目
  3. myeclipse 手动安装 lombok
  4. WPF TabControl 隐藏标头
  5. Spring MVC 线程安全问题的思考
  6. Bootstrap 更改Navbar默认样式
  7. I/B/P SP/SI
  8. 原来DataTable的Distinct竟如此简单![转]
  9. hdu Red and Black
  10. angularjs的懒加载
  11. Rabbitmq无法监听后续消息
  12. Java设计模式之接口型模式总结
  13. 【机器学习实战】第5章 Logistic回归
  14. Elasticsearch 全教程--入门
  15. BZOJ_3238_[Ahoi2013]差异_后缀自动机
  16. 软件工程(FZU2015) 赛季得分榜,第11回合(beta冲刺+SE总结)
  17. mybatics问题记录
  18. MySQL 分支的选择:Percona 还是 MariaDB
  19. 看进程的启动时间长度 + vmstat + jstack 应用
  20. 20155210潘滢昊 2016-2017-2 《Java程序设计》第8周学习总结

热门文章

  1. [css]后台管理系统布局
  2. [gj]耶稣和撒旦的关系
  3. zookeeper程序员指南
  4. impala+hdfs+parquet格式文件
  5. 第二百一十四节,jQuery EasyUI,Calendar(日历)组件
  6. 嵌入式开发之davinci--- spi 中的时钟极性CPOL和相位CPHA
  7. ISP图像调试工程师
  8. LTP4J的使用BUG及解决方案
  9. inux redis 安装配置, 以及redis php扩展
  10. Linux USB 鼠标输入驱动具体解释