Service layer that delegates to a backend CacheStore while applying:
- Key prefix: Prepended to all keyed operations (
get/set/delete/has). The prefix is also passed to the backend at construction so thatclear()can scope to it. - Default TTL: Used when
set()is called withoutttlSeconds.
clear(): Promise<void>
Delegates to the backend's clear(), which uses the construction-time
prefix to scope the deletion. CacheService does not prepend a key here
since clear() takes no key argument.
delete(key: string): Promise<boolean>
Removes a cached value.
get<T>(key: string): Promise<T | null>
Reads a cached value.
Since 0.5.0
getOrSet<T>(key: string,factory: () => Promise<T>,ttlSeconds?: number): Promise<T>
Reads a cached value or produces and stores it once for all concurrent callers of this service and key.
The in-flight registry is cleared after either success or failure. A
rejected factory therefore leaves no poisoned entry and the next caller
gets a fresh attempt. The factory result is written with the same explicit
or default TTL resolution as set.
has(key: string): Promise<boolean>
Reports whether a live entry exists.
set<T>(key: string,value: T,ttlSeconds?: number): Promise<void>
Stores a value.