storage
Classes:
-
Storage–A key-value store that evicts items based on a given policy.
Storage
Storage(
location: Path | str,
*,
size_limit: int = 1024**3,
eviction_policy: EvictionPolicy = "least-recently-used",
default_expiration: timedelta | None = None
)
A key-value store that evicts items based on a given policy.
Parameters:
-
(locationPath | str) –The location where the SQLite database should be created.
-
(size_limitint, default:1024 ** 3) –An approximate limit on the size of the cache. Approximate because the size of the cache is calculated based on the length of the stored values in bytes not the size of the SQLite file itself.
-
(eviction_policyEvictionPolicy, default:'least-recently-used') –The eviction policy to use.
-
(default_expirationtimedelta | None, default:None) –The default expiration time for items in the cache. If not specified, items will never expire unless explicitly declared at the time of setting.
Methods:
-
get_keys–Get keys from the cache.
-
get_many–Get the value for the given key.
-
get_one–Get the value for the given key.
-
set_many–Set the value for the given key.
-
set_one–Set the value for the given key.
get_keys
get_keys(check: Collection[str] | None = None) -> set[str]
Get keys from the cache.
Parameters:
-
(checkCollection[str] | None, default:None) –Keys to check the cache for. If a key is not in the cache, it will be excluded from the returned set. If None, all keys will be returned.
get_many
get_many(
keys: Collection[str] | None = None,
) -> Mapping[str, CacheItem]
Get the value for the given key.