Cache primitives with Task semantics for composable error handling.
Cache wrapper with Task semantics for composable error handling.
-
close(): Task<void, CacheCloseFailed>
Release the connection.
-
connect(connector: CacheConnector): Task<Cache, CacheConnectionFailed>
Connect to a cache via a connector.
-
delete(key: string): Task<void, CacheDeleteFailed>
Remove a key. No error if the key does not exist.
-
get<T>(key: string): Task<T | null, CacheGetFailed>
Retrieve a value by key. Returns null on cache miss.
-
getOrSet<T>(): Task<T, CacheGetFailed | CacheSetFailed>key: string,fn: () => Promisable<T>,options?: SetOptions
Get a value, or compute and store it on cache miss.
-
has(key: string): Task<boolean, CacheGetFailed>
Check whether a key exists.
-
set(): Task<void, CacheSetFailed>key: string,value: unknown,options?: SetOptions
Store a value with an optional TTL.
Close operation failed.
Connection establishment failed.
Delete operation failed.
Base error for all cache-related failures.
Get operation failed.
Set operation failed.
Creates an in-memory cache connector for testing and development.
Cache adapter interface for cache-agnostic operations.
-
close(): Promise<void>
Release any resources held by this adapter instance.
-
delete(key: string): Promise<void>
Remove a key. No error if the key does not exist.
-
get(key: string): Promise<unknown | null>
Retrieve a value by key. Returns null if the key does not exist or has expired.
-
has(key: string): Promise<boolean>
Check whether a key exists and has not expired.
-
set(): Promise<void>key: string,value: unknown,options?: SetOptions
Store a value with an optional TTL in milliseconds.
Connector that produces connected CacheAdapter instances.
-
connect(signal?: AbortSignal): Promise<CacheAdapter>
Acquire a connected adapter.
-
end(): Promise<void>
Close all connections and clean up resources.
Options for set operations.
-
ttl: number
Time-to-live in milliseconds. When omitted the entry does not expire.