AccuralAI Cache Layered

Layered cache combining fast memory and durable disk storage.

class accuralai_cache.layered.LayeredCacheOptions(*args: Any, **kwargs: Any)[source]

Bases: CacheConfig

Configuration payload for the layered cache.

promote_on_hit: bool = True
class accuralai_cache.layered.LayeredCache(*, memory_cache, disk_cache, options: LayeredCacheOptions | None = None)[source]

Bases: BaseCache

Compose two cache implementations into an L1/L2 hierarchy.

__init__(*, memory_cache, disk_cache, options: LayeredCacheOptions | None = None) None[source]
async get(key: str, *, request: GenerateRequest) GenerateResponse | None[source]
async set(key: str, value: GenerateResponse, *, ttl_s: int | None = None) None[source]
async invalidate(key: str) None[source]
async invalidate_prefix(prefix: str) None[source]

Optional hook for derived caches; default routes to individual invalidation.

async accuralai_cache.layered.build_layered_cache(*, config: Mapping[str, Any] | Any | None = None, **_: Any) LayeredCache[source]

Factory constructing the layered cache.