@dudousxd/nestjs-telescope
Version:
Laravel Telescope-style observability console for NestJS — core: watchers, recorder, correlation, SQLite store, headless API.
43 lines • 2.05 kB
TypeScript
/** Default cap on cached diagnoses. Bounds memory regardless of error variety. */
declare const DEFAULT_MAX_ENTRIES = 500;
/** Default time a cached diagnosis stays fresh: 24h. */
declare const DEFAULT_TTL_MS: number;
/**
* Bounded, TTL'd, per-pod cache of AI diagnoses keyed by exception `familyHash`.
* A family is diagnosed ONCE then served from here, so neither the operator
* clicking "Diagnose" repeatedly nor auto-mode re-running on every occurrence
* burns model tokens.
*
* PER-POD caveat: this is in-process memory. In a multi-replica deployment each
* pod caches independently, so the same family may be diagnosed up to once per
* pod. That's the same per-replica trade-off the `new-exception` tracker makes
* (documented), and it keeps the hot path a plain map lookup with no shared store.
*
* Eviction is insertion-order (`Map` iteration): at the cap the OLDEST inserted
* entry is dropped. TTL is checked lazily on read (an expired hit is a miss and
* is deleted), so stale entries don't linger as false "cached" results.
*/
export declare class DiagnosisCache {
private readonly entries;
private readonly maxEntries;
private readonly ttlMs;
private readonly now;
constructor(options?: {
maxEntries?: number;
ttlMs?: number;
now?: () => number;
});
/**
* Return the cached markdown for `familyHash`, or `null` on a miss / expiry.
* An expired entry is deleted so it can't be reported as cached.
*/
get(familyHash: string): string | null;
/** Store (or refresh) the diagnosis for `familyHash`, evicting if over cap. */
set(familyHash: string, markdown: string): void;
/** Whether a fresh diagnosis is cached for `familyHash` (TTL-aware). */
has(familyHash: string): boolean;
/** Number of live entries (test/observability seam; does not evict expired). */
get size(): number;
}
export { DEFAULT_MAX_ENTRIES as DEFAULT_DIAGNOSIS_CACHE_MAX, DEFAULT_TTL_MS as DEFAULT_DIAGNOSIS_TTL_MS, };
//# sourceMappingURL=diagnosis-cache.d.ts.map