Skip to content

Commit 7ea68ab

Browse files
committed
todo lru test
1 parent 9ea5555 commit 7ea68ab

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

docs/03_链表/lru_cache.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ def __call__(self, func):
9494
9595
- 这里为了简化默认参数只有一个数字 n,假如可以传入多个参数,如何确定缓存的key 呢?
9696
- 这里实现没有考虑线程安全的问题,要如何才能实现线程安全的 LRU 呢?当然如果不是多线程环境下使用是不需要考虑的
97-
- 假如这里没有用内置的 dict,你能使用 redis 来实现这个 LRU 吗,如果使用了 redis,我们可以存储更多数据到服务器。而使用字典实际上是换到到了Python进程里(localCache)。
97+
- 假如这里没有用内置的 dict,你能使用 redis 来实现这个 LRU 吗,如果使用了 redis,我们可以存储更多数据到服务器。而使用字典实际上是缓存了Python进程里(localCache)。
98+
- 这里只是实现了 lru 策略,你能同时实现一个超时 timeout 参数吗?比如像是memcache 实现的 lazy expiration 策略
9899
"""
99100
def _(n):
100101
if n in self.od:
@@ -125,5 +126,7 @@ def test():
125126
print(time.time() - beg)
126127

127128

129+
# TODO 要怎么给 lru 写单测?
130+
128131
if __name__ == '__main__':
129132
test()

0 commit comments

Comments
 (0)