base#
- members:
Store, NamespacedStore
- class litestar.stores.base.NamespacedStore#
Bases:
StoreA 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:
Structmsgspec.Structto store serialized data alongside with their expiry time.- classmethod new(data: bytes, expires_in: int | timedelta | None) StorageObject#
Construct a new
StorageObjectinstance.
- property expired: bool#
Return if the
StorageObjectis expired
- property expires_in: int#
Return the expiry time of this
StorageObjectin seconds. If no expiry time was set, return-1.
- classmethod from_bytes(raw: bytes) StorageObject#
Load a previously encoded with
StorageObject.to_bytes()
- class litestar.stores.base.Store#
Bases:
ABCThread 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
keyif it exists and is not expired, elseNone