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.