/** * Source Cache * * TTL-based in-memory cache for source API responses. * Supports pattern-based invalidation and cache statistics. * * @since v1.37.0 */ /** * Cache entry with data and expiry */ export interface CacheEntryData { data: T; expiry: number; createdAt: number; lastAccessed: number; } /** * Cache statistics */ export interface CacheStats { hits: number; misses: number; size: number; hitRate: number; } /** * Cache options */ export interface SourceCacheOptions { /** Default TTL in milliseconds (default: 5 minutes) */ defaultTtl?: number; /** Maximum cache size (default: 1000) */ maxSize?: number; /** Whether to log cache operations (default: false) */ debug?: boolean; /** Cache name for logging */ name?: string; } /** * TTL-based in-memory cache for source data * * @example * ```typescript * const cache = new SourceCache({ defaultTtl: 5 * 60 * 1000 }); * * // Set with default TTL * cache.set('plugin:essentialsx', pluginInfo); * * // Get (returns undefined if expired or not found) * const info = cache.get('plugin:essentialsx'); * * // Invalidate by pattern * cache.invalidate(/^plugin:/); * ``` */ export declare class SourceCache { private cache; private readonly defaultTtl; private readonly maxSize; private readonly debug; private name; private cleanupInterval; private hits; private misses; constructor(options?: SourceCacheOptions); /** Update the cache name (used after source id is available) */ setName(name: string): void; /** * Get a value from cache * Returns undefined if not found or expired */ get(key: string): T | undefined; /** * Set a value in cache */ set(key: string, data: T, ttlMs?: number): void; /** * Check if a key exists and is not expired */ has(key: string): boolean; /** * Delete a specific key */ delete(key: string): boolean; /** * Invalidate cache entries matching a pattern * If no pattern provided, clears entire cache */ invalidate(pattern?: RegExp | string): number; /** * Clear all entries */ clear(): void; /** * Get cache size */ get size(): number; /** * Get cache statistics */ getStats(): CacheStats; /** * Reset statistics */ resetStats(): void; /** * Get or set - returns cached value or fetches and caches new value */ getOrSet(key: string, fetcher: () => Promise, ttlMs?: number): Promise; /** * Cleanup expired entries */ cleanup(): number; /** * Dispose the cache, clearing the periodic cleanup interval */ dispose(): void; /** * Evict least recently used entry when at max size (LRU) */ private evictOldest; /** * Log debug message if debug mode is enabled */ private logDebug; } /** * Create a cache instance with common source defaults */ export declare function createSourceCache(name: string, ttlMs?: number): SourceCache; //# sourceMappingURL=source-cache.d.ts.map