/** * MemoryKV — AsyncKV adapter using an in-process Map * -------------------------------------------------- * Implements the AsyncKV interface: * get(key): Promise * set(key, val, ttlSec?): Promise * del(key): Promise * * Features * - Optional TTL per entry (expires on read OR via a light sweep timer) * - Perfect for tests, SSR, or Node.js CLIs * - NOT persistent across reloads/processes */ /** * * # MemoryKV (AsyncKV adapter) * * **When to use:** tests, SSR, Node.js, or quick prototyping. Not persistent. * * ```ts * import { MemoryKV, namespacedKV } from "./adapters/memory-kv"; * * const kv = new MemoryKV(); // optional sweepEveryMs * await kv.set("foo", "bar", 5); // TTL 5s * console.log(await kv.get("foo")); // "bar" * * // Namespacing (e.g., per-subject) * const ns = namespacedKV(kv, "ia:subj:alice"); * await ns.set("grants", JSON.stringify({ ... })); * ``` * * > For browsers, prefer `IndexedDBKV`. For production secrets, store encrypted blobs (SDK should encrypt before calling KV). */ export interface AsyncKV { get(key: string): Promise; set(key: string, val: string, ttlSec?: number): Promise; del(key: string): Promise; } export declare class MemoryKV implements AsyncKV { private store; private sweepHandle; private sweepEveryMs; /** * @param sweepEveryMs how often to prune expired keys (default 30s). Set 0 to disable. */ constructor(sweepEveryMs?: number); get(key: string): Promise; set(key: string, val: string, ttlSec?: number): Promise; del(key: string): Promise; /** Manually prune expired entries */ sweep(): void; /** Clear everything (useful in tests) */ clear(): void; /** Dispose background sweep timer */ dispose(): void; } export declare function namespacedKV(kv: AsyncKV, ns: string): AsyncKV; //# sourceMappingURL=memory-kv.d.ts.map