/** * Intelligent caching system for WordPress MCP Server * Implements multi-layer caching with TTL, LRU eviction, and site-specific keys */ export interface CacheEntry { value: T; timestamp: number; ttl: number; etag?: string | undefined; lastModified?: string | undefined; accessCount: number; lastAccessed: number; } export interface CacheStats { hits: number; misses: number; evictions: number; expirations: number; totalSize: number; hitRate: number; } export interface CacheConfig { maxSize: number; defaultTTL: number; enableLRU: boolean; enableStats: boolean; sitePrefix?: string; } /** * High-performance in-memory cache with TTL and LRU eviction */ export declare class CacheManager { private config; private cache; private accessOrder; private cleanupInterval; private stats; constructor(config: CacheConfig); /** * Generate cache key with site prefix and parameter hash * Uses fast non-cryptographic hash (FNV-1a) for 3-5x better performance */ generateKey(siteId: string, endpoint: string, params?: Record): string; /** * Fast non-cryptographic hash function (FNV-1a variant) * 3-5x faster than MD5 for cache key generation * Returns base36 string for compact keys with low collision risk */ private fastHash; /** * Get value from cache if not expired */ get(key: string): T | null; /** * Set value in cache with TTL */ set(key: string, value: T, ttl?: number, etag?: string, lastModified?: string): void; /** * Check if cache entry exists and is valid */ has(key: string): boolean; /** * Delete specific cache entry */ delete(key: string): boolean; /** * Clear all cache entries */ clear(): void; /** * Clear cache entries for specific site */ clearSite(siteId: string): number; /** * Clear cache entries matching pattern */ clearPattern(pattern: RegExp): number; /** * Get cache statistics */ getStats(): CacheStats; /** * Get cache entry with metadata */ getEntry(key: string): CacheEntry | null; /** * Inspect an entry's freshness without evicting it if expired, recording * the same hit/miss statistics get() would. Unlike get(), a stale entry * is not deleted here — the caller (the HTTP cache layer) may still need * its ETag/Last-Modified to issue a conditional revalidation request. * get() itself deletes expired entries as a side effect of checking * freshness, which would destroy those validators before they could be * used, so callers that need to revalidate a stale entry must use this * instead of get() + a separate expired-entry lookup. */ peek(key: string): { entry: CacheEntry | null; fresh: boolean; }; /** * Check if entry supports conditional requests */ supportsConditionalRequest(key: string): boolean; /** * Get conditional request headers */ getConditionalHeaders(key: string): Record; /** * Check if entry is expired */ private isExpired; /** * Evict least recently used entry */ private evictLRU; /** * Update access order for LRU tracking */ private updateAccessOrder; /** * Remove key from access order */ private removeFromAccessOrder; /** * Normalize parameters for consistent hashing */ private normalizeParams; /** * Update hit rate calculation */ private updateHitRate; /** * Start periodic cleanup of expired entries * Note: This uses setInterval and is not called in test environments to avoid Jest timer issues */ private startCleanupInterval; /** * Stop the cleanup interval and clean up resources */ destroy(): void; /** * Remove expired entries */ private cleanupExpired; } /** * Cache configuration presets for different data types */ export declare const CachePresets: { STATIC: { ttl: number; cacheControl: string; }; SEMI_STATIC: { ttl: number; cacheControl: string; }; DYNAMIC: { ttl: number; cacheControl: string; }; SESSION: { ttl: number; cacheControl: string; }; REALTIME: { ttl: number; cacheControl: string; }; }; //# sourceMappingURL=CacheManager.d.ts.map