Class TLRUCache
- class ooodev.utils.cache.TLRUCache(capacity, seconds)[source]
Time and Least Recently Used (LRU) Cache.
When time expires, the item is removed from the cache automatically.
- Parameters:
capacity (int) –
seconds (float) –
- __init__(capacity, seconds)[source]
Time and Least Recently Used (LRU) Cache.
- Parameters:
capacity (int) – Cache capacity.
seconds (float) – Time in seconds before item expires.
- get(key)[source]
Get value by key.
- Parameters:
key (Any) – Any Hashable object.
- Returns:
Value or
None
if not found.- Return type:
Any
Note
The
get
method is an alias for the__getitem__
method. So you can usecache_inst.get(key)
orcache_inst[key]
interchangeably.
- put(key, value)[source]
Put value by key.
- Parameters:
key (Any) – Any Hashable object.
value (Any) – Any object.
- Return type:
None
Note
The
put
method is an alias for the__setitem__
method. So you can usecache_inst.put(key, value)
orcache_inst[key] = value
interchangeably.- Return type:
None
- Parameters:
key (Any) –
value (Any) –