@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
38 lines • 1.65 kB
TypeScript
import { type ReadSpec } from '../types.ts';
/**
* Answers a client keeps of its own service, under its mount's read policy.
*
* A store's search results and a database's names never pass the
* dispatcher's cache stage, so the stage can neither bound nor drop them.
* They are kept here instead, where the mount reaches them: `govern` keeps an
* answer no longer than the mount's read policy lets it serve one unchecked,
* which is not at all under `fresh` (an answer carries no token to check) and
* within the bound under `bounded`; and the mount clears them with its own
* caches after a write that went past the dispatcher (`Accessor.forget`).
* Mirrors Python's `ResponseCache`.
*/
export declare class ResponseCache<K, V> {
private ttl;
private readonly answers;
private generation;
/**
* @param ttl seconds an answer is kept, before any mount governs it; null
* keeps it until cleared, 0 keeps nothing.
*/
constructor(ttl?: number | null);
/**
* Keep answers no longer than a mount's read policy allows. A client
* governed by several mounts (other workspaces, CLI installs) keeps the
* strictest.
*/
govern(read: ReadSpec): void;
/**
* The kept answer for `key`, else `fetch`'s, kept. An answer is kept for
* the bound from when it arrives, as the file cache keeps a read from when
* it lands, so a fetch slower than the bound is not expired as it arrives.
*/
get(key: K, fetch: () => Promise<V>): Promise<V>;
/** Drop every kept answer, and any answer still on its way. */
clear(): void;
}
//# sourceMappingURL=responses.d.ts.map