Skip to content

Commit a09513a

Browse files
committed
LRU-K
1 parent 7ea68ab commit a09513a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

docs/03_链表/lru_cache.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def __call__(self, func):
9696
- 这里实现没有考虑线程安全的问题,要如何才能实现线程安全的 LRU 呢?当然如果不是多线程环境下使用是不需要考虑的
9797
- 假如这里没有用内置的 dict,你能使用 redis 来实现这个 LRU 吗,如果使用了 redis,我们可以存储更多数据到服务器。而使用字典实际上是缓存了Python进程里(localCache)。
9898
- 这里只是实现了 lru 策略,你能同时实现一个超时 timeout 参数吗?比如像是memcache 实现的 lazy expiration 策略
99+
- LRU有个缺点就是,对于周期性的数据访问会导致命中率迅速下降,有一种优化是 LRU-K,访问了次数达到 k 次才会将数据放入缓存
99100
"""
100101
def _(n):
101102
if n in self.od:

0 commit comments

Comments
 (0)