file¶
- class litestar.stores.file.FileStore[source]¶
Bases:
NamespacedStoreFile based, thread and process safe, asynchronous key/value store.
- __init__(path: PathLike[str], *, create_directories: bool = False) None[source]¶
Initialize
FileStorage.
- path¶
file path
- create_directories¶
flag to create directories in path
- with_namespace(namespace: str) FileStore[source]¶
Return a new instance of
FileStore, using a sub-path of the current store’s path.
- async set(key: str, value: str | bytes, expires_in: int | timedelta | None = None) None[source]¶
Set a value.
- 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
- async delete(key: str) None[source]¶
Delete a value.
If no such key exists, this is a no-op.
- Parameters:
key¶ – Key of the value to delete
- async delete_all() None[source]¶
Delete all stored values.
Note
This deletes and recreates
FileStore.path