import { EventEmitter } from 'eventemitter3'; import { L as Logger } from '../logger-DUq4P1BF.mjs'; /** * Memory-based cache implementation * Provides simple in-memory caching with TTL support */ interface CacheEntry { value: T; expiresAt: number; size: number; } interface MemoryCacheOptions { maxSize?: number; defaultTTL?: number; } declare class MemoryCache { private cache; private maxSize; private defaultTTL; constructor(options?: MemoryCacheOptions); /** * Set a value in the cache */ set(key: string, value: T, ttl?: number): void; /** * Get a value from the cache */ get(key: string): T | null; /** * Check if key exists and is not expired */ has(key: string): boolean; /** * Delete a key from the cache */ delete(key: string): boolean; /** * Clear all entries */ clear(): void; /** * Get cache size */ size(): number; /** * Get all keys */ keys(): string[]; /** * Remove expired entries */ cleanup(): number; /** * Get cache statistics */ getStats(): { size: number; maxSize: number; totalSize: number; oldestEntry: number | null; newestEntry: number | null; }; /** * Evict the oldest entry */ private evictOldest; /** * Estimate size of value in bytes */ private estimateSize; } /** * LRU (Least Recently Used) Cache Implementation * Evicts least recently used entries when capacity is reached */ interface LRUCacheOptions { maxSize?: number; maxMemory?: number; defaultTTL?: number; } declare class LRUCache { private cache; private head; private tail; private maxSize; private maxMemory; private currentMemory; private defaultTTL; constructor(options?: LRUCacheOptions); /** * Set a value in the cache */ set(key: string, value: T, ttl?: number): void; /** * Get a value from the cache */ get(key: string): T | null; /** * Check if key exists and is not expired */ has(key: string): boolean; /** * Delete a key from the cache */ delete(key: string): boolean; /** * Clear all entries */ clear(): void; /** * Get cache size */ size(): number; /** * Get all keys (from most to least recently used) */ keys(): string[]; /** * Remove expired entries */ cleanup(): number; /** * Get cache statistics */ getStats(): { size: number; maxSize: number; memoryUsed: number; maxMemory: number; hitRate?: number; }; /** * Add node to head of list */ private addToHead; /** * Remove node from list */ private removeNode; /** * Move node to head of list */ private moveToHead; /** * Remove tail (least recently used) */ private removeTail; /** * Remove a key from cache */ private remove; /** * Estimate size of value in bytes */ private estimateSize; } /** * Request Deduplicator * Prevents duplicate concurrent requests for the same data */ interface DeduplicationOptions { enabled?: boolean; ttl?: number; maxPendingRequests?: number; } declare class RequestDeduplicator extends EventEmitter { private pendingRequests; private enabled; private ttl; private maxPendingRequests; private stats; constructor(options?: DeduplicationOptions); /** * Execute a request with deduplication */ execute(key: string | object, executor: () => Promise, options?: { ttl?: number; }): Promise; /** * Generate cache key from input */ private generateKey; /** * Clean up expired pending requests */ private cleanup; /** * Clear all pending requests */ clear(): void; /** * Get deduplication statistics */ getStats(): { totalRequests: number; deduplicatedRequests: number; activeDeduplications: number; deduplicationRate: number; }; /** * Enable/disable deduplication */ setEnabled(enabled: boolean): void; /** * Check if deduplication is enabled */ isEnabled(): boolean; } /** * Cache Manager * Orchestrates caching with multiple strategies */ type CacheStrategy = 'memory' | 'lru' | 'none'; interface CacheManagerOptions { strategy?: CacheStrategy; maxSize?: number; maxMemory?: number; defaultTTL?: number; deduplication?: boolean; logger?: Logger; } interface CacheStats { strategy: CacheStrategy; size: number; hits: number; misses: number; hitRate: number; deduplicationStats?: { totalRequests: number; deduplicatedRequests: number; deduplicationRate: number; }; } declare class CacheManager extends EventEmitter { private cache; private deduplicator; private strategy; private logger; private stats; constructor(options?: CacheManagerOptions); /** * Get a value from cache */ get(key: string): Promise; /** * Set a value in cache */ set(key: string, value: T, ttl?: number): Promise; /** * Get or compute a value with caching and deduplication */ getOrCompute(key: string, computer: () => Promise, options?: { ttl?: number; skipCache?: boolean; }): Promise; /** * Delete a key from cache */ delete(key: string): Promise; /** * Check if key exists in cache */ has(key: string): Promise; /** * Clear all cache entries */ clear(): Promise; /** * Get cache size */ size(): number; /** * Get all keys */ keys(): string[]; /** * Clean up expired entries */ cleanup(): number; /** * Get cache statistics */ getStats(): CacheStats; /** * Generate cache key from request parameters */ static generateKey(params: Record): string; /** * Enable/disable deduplication */ setDeduplicationEnabled(enabled: boolean): void; /** * Check if deduplication is enabled */ isDeduplicationEnabled(): boolean; } export { type CacheEntry, CacheManager, type CacheManagerOptions, type CacheStats, type CacheStrategy, type DeduplicationOptions, LRUCache, type LRUCacheOptions, MemoryCache, type MemoryCacheOptions, RequestDeduplicator };