/** * @file Request Cache * @description Request deduplication and caching utilities */ /** * Cache configuration */ export interface CacheConfig { /** Default TTL in milliseconds */ defaultTtl?: number; /** Maximum cache entries */ maxEntries?: number; /** Enable request deduplication */ deduplication?: boolean; /** Deduplication window (ms) */ deduplicationWindow?: number; } /** * Request cache class */ export declare class RequestCache { private cache; private pending; private config; private gcIntervalId; constructor(config?: CacheConfig); /** * Dispose of the cache and clean up resources */ dispose(): void; /** * Generate cache key */ generateKey(url: string, params?: Record, body?: unknown): string; /** * Get cached value */ get(key: string): T | undefined; /** * Set cached value */ set(key: string, data: T, ttl?: number): void; /** * Check if key exists and is valid */ has(key: string): boolean; /** * Delete cached value */ delete(key: string): boolean; /** * Clear all cached values */ clear(): void; /** * Clear expired entries */ clearExpired(): void; /** * Execute with deduplication */ dedupe(key: string, fetcher: () => Promise, options?: { ttl?: number; }): Promise; /** * Invalidate cache entries by pattern */ invalidatePattern(pattern: string | RegExp): void; /** * Get cache statistics */ getStats(): { size: number; maxEntries: number; pendingRequests: number; }; /** * Evict oldest entry */ private evictOldest; } /** * Default request cache instance */ export declare const requestCache: RequestCache; /** * Create a cached fetcher */ export declare function createCachedFetcher(fetcher: () => Promise, key: string, options?: { ttl?: number; cache?: RequestCache; }): () => Promise; /** * HOF for caching function results */ export declare function withCache(fn: (...args: Args) => Promise, keyGenerator: (...args: Args) => string, options?: { ttl?: number; cache?: RequestCache; }): (...args: Args) => Promise;