import { type Maybe } from '../value/maybe.type'; /** * Async cache for a single value of type T. * * Implementations may be in-memory, file-backed, network-backed, or composed via * {@link memoizeAsyncValueCache} / {@link mergeAsyncValueCaches}. */ export interface AsyncValueCache { /** * Loads the value from the cache, or returns null/undefined when no value is stored. */ load(): Promise>; /** * Stores the value in the cache, replacing any previously stored value. */ update(value: T): Promise; /** * Removes the stored value and any persistent backing. */ clear(): Promise; } /** * Async cache for a record of T entries keyed by string. * * Implementations may be in-memory, file-backed (one file holds all keys), or composed. */ export interface AsyncKeyedValueCache { /** * Loads the full record from the cache. Returns an empty object when the cache is empty. */ load(): Promise>; /** * Returns the entry for the given key, or null/undefined when no entry is stored. */ get(key: string): Promise>; /** * Stores the entry for the given key, replacing any previous entry at that key. */ set(key: string, value: T): Promise; /** * Removes the entry for the given key, leaving other keys intact. */ remove(key: string): Promise; /** * Removes all entries and any persistent backing. */ clear(): Promise; }