export interface TtlCacheEntry { value: V; createdAt: number; lastUsed: number; version?: string; } export interface TtlLruCacheOptions { /** 条目最大存活毫秒数;超过则视为过期并在 reap 时淘汰 */ ttlMs: number; /** 容量上限;超过时按 idle(最久未用优先)强制淘汰未过期项 */ maxSize?: number; /** * 淘汰回调:当条目因过期或容量超限被移除时调用,用于释放资源 * (如 AgentEngine.destroy)。可选。 */ onEvict?: (value: any) => void; } /** * 通用缓存:支持 TTL 过期清理与容量超限时的 LRU 强制淘汰。 * 被 EnginePool 与 agent-server 的客户端池复用,避免重复实现。 */ export declare class TtlLruCache { private readonly map; private readonly ttlMs; private readonly maxSize; private readonly onEvict?; constructor(options: TtlLruCacheOptions); get(key: string): V | null; getWithVersion(key: string): { value: V; version?: string; } | null; set(key: string, value: V, version?: string): void; has(key: string): boolean; delete(key: string): void; clear(): void; get size(): number; /** 枚举所有缓存值(不含过期判定) */ values(): V[]; /** 判断是否过期(不触发淘汰,仅作判定) */ private isExpired; private remove; /** * 清理过期项;若清理后 size 仍超过 maxSize,按 idle 降序(最久未用优先) * 强制淘汰未过期项,直至 size <= maxSize。 */ reapStale(): void; } //# sourceMappingURL=ttl-lru-cache.d.ts.map