五、memcache 的LRU算法
memcache 的LRU
memcache 的LRU 这个分为老版本和 新版本。
参考这个博文:
https://www.jianshu.com/p/db620e82e309
1.5以前的 用的是老的 LRU
然后:如这篇所讲
https://www.jianshu.com/p/1f54c7abfe3d
https://www.jianshu.com/p/e3dcbd904721
1.5开始实现了 分段LRU, 数据分为 HOT, WARM, COLD,并且新增了 maintainer 和 crawler 线程
里面有个名词: bump
当 get 一个 item,它会从链表中 unlink,然后重新 link 到链表的 head,这个过程叫做 bump。
由于 bump 会有锁(mutex locks and mutations),频繁发生对性能有非常大的影响,所以 memcached 做了一个优化,在 60 秒内同一个 item 只会产生一次 bump。