tlc.service.lru_cache_store

Module Contents

Classes

Class

Description

LRUCacheStoreConfig

LRUCache backend configuration.

LRUCacheStore

In-memory LRU cache backend.

API

class tlc.service.lru_cache_store.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

class tlc.service.lru_cache_store.LRUCacheStore(config: tlc.service.lru_cache_store.LRUCacheStoreConfig)

Bases: litestar.stores.base.Store

In-memory LRU cache backend.

Initialize LRUCacheBackend

stats() dict[str, int]
async get(key: str, renew_for: int | datetime.timedelta | None = None) bytes | None
async set(key: str, value: str | bytes, expires_in: int | datetime.timedelta | None = None) None
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.