/** * SMI-644: Enhanced Tiered Cache with TTL Management * L1 (memory) + L2 (SQLite) with automatic promotion/demotion */ import type { SearchResult } from './lru.js'; import { TTLTier } from './CacheEntry.js'; /** L1 cache configuration */ export interface L1Config { maxEntries?: number; maxMemoryBytes?: number; } /** L2 cache configuration */ export interface L2Config { dbPath: string; pruneIntervalMs?: number; } /** Combined tiered cache configuration */ export interface TieredCacheConfig { l1?: L1Config; l2?: L2Config; enablePromotion?: boolean; enableDemotion?: boolean; } /** Cache statistics */ export interface TieredCacheStats { l1Hits: number; l1Misses: number; l2Hits: number; l2Misses: number; totalHits: number; totalMisses: number; hitRate: number; l1Size: number; l2Size: number; promotions: number; demotions: number; evictions: number; popularEntries: number; rareEntries: number; } /** * Enhanced two-tier cache with TTL management */ export declare class EnhancedTieredCache { private l1; private db; private config; private pruneTimer; private stats; private stmts; /** * @deprecated If l2.dbPath is passed, use EnhancedTieredCache.create(config) instead — * the async factory supports both native and WASM SQLite. Passing l2.dbPath to this * constructor throws to prevent silent data loss. */ constructor(config?: TieredCacheConfig); /** * Async factory — supports both native and WASM SQLite. * * @param config - Cache configuration; l2.dbPath is opened via createDatabaseAsync * @returns Fully initialised EnhancedTieredCache instance */ static create(config?: TieredCacheConfig): Promise; private initFromConfig; private initL2Async; /** * Get entry from cache (L1 first, then L2) */ get(key: string): { results: SearchResult[]; totalCount: number; } | undefined; /** * Store entry in cache */ set(key: string, results: SearchResult[], totalCount: number, ttlTier?: TTLTier): void; /** * Check if key exists in cache */ has(key: string): boolean; /** * Delete specific entry */ delete(key: string): boolean; /** * Invalidate all entries (called on index update) */ invalidateAll(): void; /** * Prune expired entries */ prune(): number; /** * Get entries that need background refresh */ getEntriesNeedingRefresh(): string[]; /** * Get cache statistics */ getStats(): TieredCacheStats; /** * Demote entry from L1 to L2 */ private demoteToL2; /** * Close cache and cleanup resources */ close(): void; } //# sourceMappingURL=TieredCache.d.ts.map