base¶
- members:
Store, NamespacedStore
- class litestar.stores.base.NamespacedStore[source]¶
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.
- abstractmethod with_namespace(namespace: str) Self[source]¶
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[source]¶
Bases:
Structmsgspec.Structto store serialized data alongside with their expiry time.- classmethod new(data: bytes, expires_in: int | timedelta | None) StorageObject[source]¶
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[source]¶
Load a previously encoded with
StorageObject.to_bytes()
- class litestar.stores.base.Store[source]¶
Bases:
ABCThread and process safe asynchronous key/value store.
- abstractmethod async set(key: str, value: str | bytes, expires_in: int | timedelta | None = None) None[source]¶
Set a value.
- abstractmethod async get(key: str, renew_for: int | timedelta | None = None) bytes | None[source]¶
Get a value.
- Parameters:
- Returns:
The value associated with
keyif it exists and is not expired, elseNone