caching

Utilities related to custom caches.

class AsyncCache(max_size=128)[source]

Bases: object

LRU cache implementation for coroutines.

Once the cache exceeds the maximum size, keys are deleted in FIFO order.

An offset may be optionally provided to be applied to the coroutine’s arguments when creating the cache key.

__call__(arg_offset=0)[source]

Decorator for async cache.

Parameters:

arg_offset (int) – The offset for the position of the key argument.

Return type:

Callable

Returns:

A decorator to wrap the target function.

__init__(max_size=128)[source]

Initialise a new AsyncCache instance.

Parameters:

max_size (int) – How many items to store in the cache.

clear()[source]

Clear cache instance.

Return type:

None