/** * CacheMemoryBudget - Global memory coordinator for LRU cache instances * * Tracks aggregate memory usage across all registered LRU caches and enforces * a configurable global ceiling. When total memory exceeds the budget, evicts * entries from the least-active (coldest) cache first. * * Phase 4 of the Cache Consolidation RFC (CACHE-DESIGN.md). */ import { LRUCache } from './LRUCache.js'; export interface CacheMemoryBudgetOptions { /** Global memory limit in bytes (default: 150 MB) */ globalLimitBytes: number; /** Maximum evictions per enforce() call to prevent runaway loops (default: 50) */ maxEvictionsPerEnforce?: number; } export interface BudgetCacheReport { name: string; entries: number; memoryMB: number; hitRate: number; lastActivityMs: number; } export interface BudgetReport { caches: BudgetCacheReport[]; totalMemoryMB: number; budgetMB: number; utilizationPercent: number; } export declare class CacheMemoryBudget { private readonly registeredCaches; private readonly globalLimitBytes; private readonly maxEvictionsPerEnforce; private enforcing; constructor(options: CacheMemoryBudgetOptions); /** * Register a cache instance with this budget. Idempotent. */ register(cache: LRUCache): void; /** * Unregister a cache instance (e.g., during dispose). Idempotent. */ unregister(cache: LRUCache): void; /** * Get the number of registered caches. */ getRegisteredCacheCount(): number; /** * Get the sum of memory usage across all registered caches. */ getTotalMemoryBytes(): number; /** * Enforce the global memory budget by evicting entries from the coldest * (least recently active) cache until total usage is under the limit. * * Called automatically via onSet callbacks registered on each cache. * Includes a reentrancy guard to prevent cascading enforcement. */ enforce(): void; /** * Get a diagnostic report of all registered caches. */ getReport(): BudgetReport; } //# sourceMappingURL=CacheMemoryBudget.d.ts.map