import { CacheStats } from './interfaces/cache-provider'; import { CacheOptions, InvalidationOptions } from './interfaces/cache-options'; import { LockManager, LockOptions } from './interfaces/lock'; /** * CacheManager provides a unified interface to various caching strategies */ export declare class CacheManager { private provider; private options; private invalidator; private lockManager?; private logger; /** * Creates a new CacheManager instance * @param options Cache options */ constructor(options?: CacheOptions); /** * Create the appropriate cache provider based on options */ private createProvider; /** * Get a value from the cache * @param key Cache key * @returns Promise resolving to the cached value or undefined if not found */ get(key: string): Promise; /** * Set a value in the cache * @param key Cache key * @param value Value to cache * @param ttl Time-to-live in milliseconds (optional) * @param invalidationOptions Optional invalidation options * @returns Promise resolving to true if successful */ set(key: string, value: T, ttl?: number, invalidationOptions?: InvalidationOptions): Promise; /** * Delete a value from the cache * @param key Cache key * @returns Promise resolving to true if successful */ delete(key: string): Promise; /** * Check if a key exists in the cache * @param key Cache key * @returns Promise resolving to true if the key exists */ has(key: string): Promise; /** * Clear all values from the cache * @returns Promise resolving to true if successful */ clear(): Promise; /** * Get multiple values from the cache * @param keys Array of cache keys * @returns Promise resolving to a map of key-value pairs for found items */ getMany(keys: string[]): Promise>; /** * Set multiple values in the cache * @param entries Map of key-value pairs to cache * @param ttl Time-to-live in milliseconds (optional) * @returns Promise resolving to true if successful */ setMany(entries: Map, ttl?: number): Promise; /** * Delete multiple values from the cache * @param keys Array of cache keys to delete * @returns Promise resolving to true if successful */ deleteMany(keys: string[]): Promise; /** * Get or set a value in the cache (retrieve if exists, otherwise generate and store) * @param key Cache key * @param factory Function to generate value if not found in cache * @param ttl Time-to-live in milliseconds (optional) * @param invalidationOptions Optional invalidation options * @returns Promise resolving to the value */ getOrSet(key: string, factory: () => Promise, ttl?: number, invalidationOptions?: InvalidationOptions): Promise; /** * Wrap a function with caching * @param fn Function to wrap * @param keyGenerator Function to generate cache key from args * @param ttl Time-to-live in milliseconds (optional) * @param invalidationOptions Optional invalidation options * @returns Wrapped function with caching */ wrap(fn: (...args: A) => Promise, keyGenerator: (...args: A) => string, ttl?: number, invalidationOptions?: InvalidationOptions): (...args: A) => Promise; /** * Wrap a function with caching and lock for exclusive access * @param fn Function to wrap * @param keyGenerator Function to generate cache key from args * @param lockOptions Options for locking * @param ttl Time-to-live in milliseconds (optional) * @param invalidationOptions Optional invalidation options * @returns Wrapped function with caching and locking */ wrapWithLock(fn: (...args: A) => Promise, keyGenerator: (...args: A) => string, lockOptions?: LockOptions & { ttl?: number; }, ttl?: number, invalidationOptions?: InvalidationOptions): (...args: A) => Promise; /** * Invalidate cache entries * @param pattern Pattern to match (for pattern invalidation) * @param tags Tags to invalidate (for tag invalidation) * @param namespace Namespace to invalidate (for version invalidation) * @returns Promise resolving to the number of invalidated entries */ invalidate(pattern?: string, tags?: string[], namespace?: string): Promise; /** * Get cache stats * @returns Promise resolving to cache statistics */ getStats(): Promise; /** * Connect to the cache backend * @returns Promise resolving when connected */ connect(): Promise; /** * Disconnect from the cache backend * @returns Promise resolving when disconnected */ disconnect(): Promise; /** * Ensure lock manager is initialized */ private ensureLockManager; /** * Get the lock manager instance * @returns Lock manager instance */ getLockManager(): LockManager; /** * Format a key according to configured prefix * @param key Original key * @returns Formatted key */ private formatKey; /** * Get the original key from a formatted key * @param formattedKey Formatted key * @returns Original key */ private getOriginalKey; /** * Generate a cache key from an object * @param obj Object to generate key from * @param options Key generation options * @returns Generated cache key */ static generateKey(obj: any, options?: any): string; } //# sourceMappingURL=cache-manager.d.ts.map