cachetoolsPython 模塊
cachetools 是一個 Python 模塊,提供各種記憶集合和修飾符,包括 Python 3 標準庫的 @lru_cache 函數(shù)修飾符。
>>> from cachetools import LRUCache
>>> cache = LRUCache(maxsize=2)
>>> cache.update([('first', 1), ('second', 2)])
>>> cache
LRUCache([('second', 2), ('first', 1)], maxsize=2, currsize=2)
>>> cache['third'] = 3
>>> cache
LRUCache([('second', 2), ('third', 3)], maxsize=2, currsize=2)
>>> cache['second']
2
>>> cache['fourth'] = 4
>>> cache
LRUCache([('second', 2), ('fourth', 4)], maxsize=2, currsize=2)評論
圖片
表情
