skytracker.storage.cache.Cache#

class skytracker.storage.cache.Cache#

Bases: Generic[T]

Generic async-safe cache for storing batch of items

Methods

__init__

Initialize cache data storage and async lock

clear

Clear the cache

empty

Check if the cache is empty

get

Get the cached items

length

Get the number of items stored in the cache

set

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