skytracker.storage.cache.Cache#
- class skytracker.storage.cache.Cache#
Bases:
Generic[T]Generic async-safe cache for storing batch of items
Methods
Initialize cache data storage and async lock
Clear the cache
Check if the cache is empty
Get the cached items
Get the number of items stored in the cache
Replace cache contents with new batch of items
- __init__()#
Initialize cache data storage and async lock
- async clear() None#
Clear the cache
- async empty() bool#
Check if the cache is empty
- Returns:
whether cache is empty
- Return type:
bool
- async get(limit: int = 0) List[T]#
Get the cached items
- Parameters:
limit (int, optional) – maximum number of states to get (0 = all)
- Returns:
copy of cached items
- Return type:
List[T]
- async length() int#
Get the number of items stored in the cache
- Returns:
number of items in cache
- Return type:
int
- async set(items: List[T]) None#
Replace cache contents with new batch of items
- Parameters:
items (List[T]) – new batch of items to cache