aries_cloudagent.cache package

Submodules

aries_cloudagent.cache.base module

Abstract base classes for cache.

class aries_cloudagent.cache.base.BaseCache[source]

Bases: abc.ABC

Abstract cache interface.

acquire(key: str)[source]

Acquire a lock on a given cache key.

clear(key: str)[source]

Remove an item from the cache, if present.

Parameters:key – the key to remove
flush()[source]

Remove all items from the cache.

get(key: str)[source]

Get an item from the cache.

Parameters:key – the key to retrieve an item for
Returns:The record found or None
release(key: str)[source]

Release the lock on a given cache key.

set(keys: Union[str, Sequence[str]], value: Any, ttl: int = None)[source]

Add an item to the cache with an optional ttl.

Parameters:
  • keys – the key or keys for which to set an item
  • value – the value to store in the cache
  • ttl – number of second that the record should persist
exception aries_cloudagent.cache.base.CacheError(*args, error_code: str = None, **kwargs)[source]

Bases: aries_cloudagent.core.error.BaseError

Base class for cache-related errors.

class aries_cloudagent.cache.base.CacheKeyLock(cache: aries_cloudagent.cache.base.BaseCache, key: str)[source]

Bases: object

A lock on a particular cache key.

Used to prevent multiple async threads from generating or querying the same semi-expensive data. Not thread safe.

done

Accessor for the done state.

future

Fetch the result in the form of an awaitable future.

parent

Accessor for the parent key lock, if any.

release()[source]

Release the cache lock.

result

Fetch the current result, if any.

set_result(value: Any, ttl: int = None)[source]

Set the result, updating the cache and any waiters.

aries_cloudagent.cache.basic module

Basic in-memory cache implementation.

class aries_cloudagent.cache.basic.BasicCache[source]

Bases: aries_cloudagent.cache.base.BaseCache

Basic in-memory cache class.

clear(key: str)[source]

Remove an item from the cache, if present.

Parameters:key – the key to remove
flush()[source]

Remove all items from the cache.

get(key: str)[source]

Get an item from the cache.

Parameters:key – the key to retrieve an item for
Returns:The record found or None
set(keys: Union[str, Sequence[str]], value: Any, ttl: int = None)[source]

Add an item to the cache with an optional ttl.

Overwrites existing cache entries.

Parameters:
  • keys – the key or keys for which to set an item
  • value – the value to store in the cache
  • ttl – number of seconds that the record should persist