base#
- members:
Store, NamespacedStore
- class litestar.stores.base.Store#
Bases:
ABC
Thread and process safe asynchronous key/value store.
- abstract async set(key: str, value: str | bytes, expires_in: int | timedelta | None = None) None #
Set a value.
- abstract async get(key: str, renew_for: int | timedelta | None = None) bytes | None #
Get a value.
- Parameters:
- Returns:
The value associated with
key
if it exists and is not expired, elseNone
- class litestar.stores.base.NamespacedStore#
Bases:
Store
A subclass of
Store
, offering hierarchical namespacing.Bulk actions on a parent namespace should affect all child namespaces, whereas other operations on all namespaces should be isolated.
- abstract with_namespace(namespace: str) Self #
Return a new instance of
NamespacedStore
, which exists in a child namespace of the current namespace. Bulk actions on the parent namespace should affect all child namespaces, whereas other operations on all namespaces should be isolated.
- class litestar.stores.base.StorageObject#
Bases:
Struct
msgspec.Struct
to store serialized data alongside with their expiry time.- classmethod new(data: bytes, expires_in: int | timedelta | None) StorageObject #
Construct a new
StorageObject
instance.
- property expired: bool#
Return if the
StorageObject
is expired
- property expires_in: int#
Return the expiry time of this
StorageObject
in seconds. If no expiry time was set, return-1
.
- classmethod from_bytes(raw: bytes) StorageObject #
Load a previously encoded with
StorageObject.to_bytes()