linkahead.cached module

This module provides some cached versions of functions that retrieve Entities from a remote server.

See also

-, -, -, -, id,

class linkahead.cached.AccessType(value)

Bases: Enum

Different access types for cached queries. Needed for filling the cache manually with cache_fill() .

EID = 3
NAME = 4
PATH = 2
QUERY = 1
linkahead.cached.cache_clear() None

Empty the cache that is used by cached_query and cached_get_entity_by.

linkahead.cached.cache_fill(items: dict[str | int, Any], kind: AccessType = AccessType.EID, unique: bool = True) None

Add entries to the cache manually.

This allows to fill the cache without actually submitting queries. Note that this does not overwrite existing entries with the same keys.

Parameters:
linkahead.cached.cache_info()

Return info about the cache that is used by cached_query and cached_get_entity_by.

Returns:

out – See the standard library functools.lru_cache() for details.

Return type:

named tuple

linkahead.cached.cache_initialize(maxsize: int = 33333) None

Create a new cache with the given size for cached_query and cached_get_entity_by.

This implies a call of cache_clear(), the old cache is emptied.

linkahead.cached.cached_get_entity_by(eid: str | int | None = None, name: str | None = None, path: str | None = None, query: str | None = None) Entity | tuple[None]

Return a single entity that is identified uniquely by one argument.

You must supply exactly one argument.

If a query phrase is given, the result must be unique. If this is not what you need, use cached_query() instead.

linkahead.cached.cached_query(query_string: str) Container

A cached version of linkahead.execute_query.

All additional arguments are at their default values.