Skip to content

Caching

Caching

Classes:

Name Description
BaseCache

Base class for a cache.

BaseCache

Bases: ABC, Generic[ValueT]

Base class for a cache.

Methods:

Name Description
__init__

Initialize the cache with a serializer.

get

Get the cached values for the given keys.

aget

Asynchronously get the cached values for the given keys.

set

Set the cached values for the given keys and TTLs.

aset

Asynchronously set the cached values for the given keys and TTLs.

clear

Delete the cached values for the given namespaces.

aclear

Asynchronously delete the cached values for the given namespaces.

__init__

__init__(
    *, serde: SerializerProtocol | None = None
) -> None

Initialize the cache with a serializer.

get abstractmethod

get(keys: Sequence[FullKey]) -> dict[FullKey, ValueT]

Get the cached values for the given keys.

aget abstractmethod async

aget(keys: Sequence[FullKey]) -> dict[FullKey, ValueT]

Asynchronously get the cached values for the given keys.

set abstractmethod

set(
    pairs: Mapping[FullKey, tuple[ValueT, int | None]],
) -> None

Set the cached values for the given keys and TTLs.

aset abstractmethod async

aset(
    pairs: Mapping[FullKey, tuple[ValueT, int | None]],
) -> None

Asynchronously set the cached values for the given keys and TTLs.

clear abstractmethod

clear(
    namespaces: Sequence[Namespace] | None = None,
) -> None

Delete the cached values for the given namespaces. If no namespaces are provided, clear all cached values.

aclear abstractmethod async

aclear(
    namespaces: Sequence[Namespace] | None = None,
) -> None

Asynchronously delete the cached values for the given namespaces. If no namespaces are provided, clear all cached values.

Classes:

Name Description
InMemoryCache

InMemoryCache

Bases: BaseCache[ValueT]

Methods:

Name Description
get

Get the cached values for the given keys.

aget

Asynchronously get the cached values for the given keys.

set

Set the cached values for the given keys.

aset

Asynchronously set the cached values for the given keys.

clear

Delete the cached values for the given namespaces.

aclear

Asynchronously delete the cached values for the given namespaces.

get

get(keys: Sequence[FullKey]) -> dict[FullKey, ValueT]

Get the cached values for the given keys.

aget async

aget(keys: Sequence[FullKey]) -> dict[FullKey, ValueT]

Asynchronously get the cached values for the given keys.

set

set(
    keys: Mapping[FullKey, tuple[ValueT, int | None]],
) -> None

Set the cached values for the given keys.

aset async

aset(
    keys: Mapping[FullKey, tuple[ValueT, int | None]],
) -> None

Asynchronously set the cached values for the given keys.

clear

clear(
    namespaces: Sequence[Namespace] | None = None,
) -> None

Delete the cached values for the given namespaces. If no namespaces are provided, clear all cached values.

aclear async

aclear(
    namespaces: Sequence[Namespace] | None = None,
) -> None

Asynchronously delete the cached values for the given namespaces. If no namespaces are provided, clear all cached values.

Classes:

Name Description
SqliteCache

File-based cache using SQLite.

SqliteCache

Bases: BaseCache[ValueT]

File-based cache using SQLite.

Methods:

Name Description
__init__

Initialize the cache with a file path.

get

Get the cached values for the given keys.

aget

Asynchronously get the cached values for the given keys.

set

Set the cached values for the given keys and TTLs.

aset

Asynchronously set the cached values for the given keys and TTLs.

clear

Delete the cached values for the given namespaces.

aclear

Asynchronously delete the cached values for the given namespaces.

__init__

__init__(
    *, path: str, serde: SerializerProtocol | None = None
) -> None

Initialize the cache with a file path.

get

get(keys: Sequence[FullKey]) -> dict[FullKey, ValueT]

Get the cached values for the given keys.

aget async

aget(keys: Sequence[FullKey]) -> dict[FullKey, ValueT]

Asynchronously get the cached values for the given keys.

set

set(
    mapping: Mapping[FullKey, tuple[ValueT, int | None]],
) -> None

Set the cached values for the given keys and TTLs.

aset async

aset(
    mapping: Mapping[FullKey, tuple[ValueT, int | None]],
) -> None

Asynchronously set the cached values for the given keys and TTLs.

clear

clear(
    namespaces: Sequence[Namespace] | None = None,
) -> None

Delete the cached values for the given namespaces. If no namespaces are provided, clear all cached values.

aclear async

aclear(
    namespaces: Sequence[Namespace] | None = None,
) -> None

Asynchronously delete the cached values for the given namespaces. If no namespaces are provided, clear all cached values.