tlc.service.lru_cache_store¶

Module Contents¶

Classes¶

Class

Description

LRUCacheStore

In-memory LRU cache backend.

LRUCacheStoreConfig

LRUCache backend configuration.

API¶

class LRUCacheStore(
config: LRUCacheStoreConfig,
)¶

Bases: litestar.stores.base.Store

In-memory LRU cache backend.

Initialize LRUCacheBackend

async delete(
key: str,
) None¶
async delete_all() None¶
async exists(
key: str,
) bool¶
async expires_in(
key: str,
) int | None¶

Get the time in seconds key expires in. If no such key exists or no expiry time was set, return None.

async get(
key: str,
renew_for: int | timedelta | None = None,
) bytes | None¶
async set(
key: str,
value: str | bytes,
expires_in: int | timedelta | None = None,
) None¶
stats() dict[str, int]¶
class LRUCacheStoreConfig(
/,
**data: typing.Any,
)¶

Bases: pydantic.BaseModel

LRUCache backend configuration.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

max_entries: int = 50000¶

Available slots

max_memory_in_bytes: int = 1073741824¶

Maximum memory to use for the cache

time_out_in_seconds: float = 3600¶

Cache time out for the items