/** * State cache with TTL-based expiry and SHA-256 ETag support. * * Provides a lightweight in-memory cache for sidecar state snapshots, * session data, and delegations. Each entry stores the cached value, * a computed ETag for HTTP conditional requests, and an expiry timestamp. * * @module sidecar/server/cache */ /** A single cache entry with ETag and TTL metadata. */ export interface CacheEntry { data: T; etag: string; expiresAt: number; } /** Cache category used to select the default TTL. */ export type CacheCategory = "snapshot" | "session" | "delegations" | "docs"; /** * In-memory state cache with per-category TTLs and SHA-256 ETag. * * All operations are synchronous and benefit from Node's single-threaded * event loop (no concurrent access races on the internal Map). * * @typeParam T - The type of data stored in each entry. * * @example * ```ts * const cache = new SidecarStateCache() * const etag = cache.set("sess-1", { id: "sess-1" }, "session") * const entry = cache.get<{ id: string }>("sess-1", "session") * cache.invalidate("all") * ``` */ export declare class SidecarStateCache { #private; /** * Retrieve a cached entry if it has not expired. * * Expired entries are evicted before returning `undefined`. * * @param key - Cache key (typically a URL path or session ID). * @param category - Category for TTL selection (unused on read). * @returns The cached data, or `undefined` if missing/expired. */ get(key: string, _category?: CacheCategory): T | undefined; /** * Store a value in the cache. * * Computes a SHA-256 ETag from `JSON.stringify(data)`. * * @param key - Cache key. * @param data - Value to cache. * @param category - Category used to select the default TTL. * @returns The computed ETag (strong, quoted per HTTP spec). * @throws `[Hivemind]` on serialisation failure. */ set(key: string, data: T, category?: CacheCategory): string; /** * Invalidate all entries matching a category or all entries. * * When `category` is `"all"` the entire cache is cleared. * * @param category - Category to evict, or `"all"` for full clear. */ invalidate(category: CacheCategory | "all"): void; } //# sourceMappingURL=cache.d.ts.map