
LRU
varyall
这个作者很懒,什么都没留下…
展开
-
两种常见的缓存淘汰算法LFU&LRU
1. LFU1.1. 原理LFU(Least Frequently Used)算法根据数据的历史访问频率来淘汰数据,其核心思想是“如果数据过去被访问多次,那么将来被访问的频率也更高”。1.2. 实现LFU的每个数据块都有一个引用计数,所有数据块按照引用计数排序,具有相同引用计数的数据块则按照时间排序。具体实现如下: 1. 新加入数据插入到队列尾部(因为引用计数为1);2. 队列中的数据被访问后,引转载 2018-01-18 19:18:15 · 4432 阅读 · 0 评论 -
146. LRU Cache
1.The key to solve this problem is using a double linked list which enables us to quickly move nodes. 2.The LRU cache is a hash table of keys and double linked nodes. The hash table makes the time of ...转载 2018-08-31 19:01:16 · 164 阅读 · 0 评论