/**
 * LRU Cache System
 * Provides efficient caching for frequently accessed data with automatic eviction.
 *
 * Features:
 * - Configurable max size and TTL (time-to-live)
 * - Automatic eviction of least recently used items
 * - TTL-based expiration for stale data
 * - Statistics tracking for monitoring
 * - Type-safe generic implementation
 */
export interface CacheEntry<T> {
    value: T;
    createdAt: number;
    lastAccessedAt: number;
    accessCount: number;
}
export interface CacheStats {
    size: number;
    maxSize: number;
    hits: number;
    misses: number;
    hitRate: number;
    evictions: number;
    expirations: number;
}
export interface CacheOptions {
    maxSize?: number;
    ttlMs?: number;
    onEvict?: (key: string, value: unknown) => void;
}
/**
 * LRU (Least Recently Used) Cache with TTL support.
 *
 * When the cache reaches maxSize, the least recently accessed items are evicted.
 * Items also expire after ttlMs milliseconds if set.
 */
export declare class LRUCache<T = unknown> {
    private cache;
    private maxSize;
    private ttlMs;
    private onEvict;
    private hits;
    private misses;
    private evictions;
    private expirations;
    /**
     * Create a new LRU cache.
     *
     * @param maxSize - Maximum number of entries (default: 1000)
     * @param ttlMs - Time-to-live in milliseconds (default: null = no expiration)
     * @param onEvict - Optional callback when an entry is evicted
     */
    constructor(options?: CacheOptions);
    /**
     * Get a value from the cache.
     * Returns undefined if the key doesn't exist or has expired.
     *
     * @param key - Cache key
     * @returns Cached value or undefined
     */
    get(key: string): T | undefined;
    /**
     * Set a value in the cache.
     * If the cache is full, the least recently used item is evicted.
     *
     * @param key - Cache key
     * @param value - Value to cache
     * @returns The cache instance for chaining
     */
    set(key: string, value: T): this;
    /**
     * Check if a key exists in the cache (without updating access time).
     *
     * @param key - Cache key
     * @returns true if key exists and is not expired
     */
    has(key: string): boolean;
    /**
     * Delete a key from the cache.
     *
     * @param key - Cache key
     * @returns true if the key was deleted
     */
    delete(key: string): boolean;
    /**
     * Clear all entries from the cache.
     */
    clear(): void;
    /**
     * Get the current size of the cache.
     */
    get size(): number;
    /**
     * Get all keys in the cache.
     */
    keys(): string[];
    /**
     * Get all values in the cache.
     */
    values(): T[];
    /**
     * Get cache statistics.
     */
    getStats(): CacheStats;
    /**
     * Remove expired entries from the cache.
     *
     * @returns Number of expired entries removed
     */
    cleanup(): number;
    /**
     * Get or set a value using a factory function.
     * If the key doesn't exist, calls the factory and caches the result.
     *
     * @param key - Cache key
     * @param factory - Function to create the value if not cached
     * @returns The cached or newly created value
     */
    getOrSet(key: string, factory: () => T | Promise<T>): Promise<T>;
    /**
     * Get or set a value synchronously using a factory function.
     *
     * @param key - Cache key
     * @param factory - Synchronous function to create the value if not cached
     * @returns The cached or newly created value
     */
    getOrSetSync(key: string, factory: () => T): T;
    /**
     * Check if an entry has expired.
     */
    private isExpired;
    /**
     * Evict the least recently used entry.
     */
    private evictLRU;
}
/**
 * Cache specifically for database query results.
 * Includes query normalization and result serialization.
 */
export declare class QueryCache extends LRUCache<unknown> {
    /**
     * Create a cache key from a query and parameters.
     */
    static createKey(query: string, params?: unknown[]): string;
    /**
     * Get cached query result.
     */
    getQuery<R>(query: string, params?: unknown[]): R | undefined;
    /**
     * Cache a query result.
     */
    setQuery<R>(query: string, params: unknown[] | undefined, result: R): this;
    /**
     * Invalidate all cached queries matching a pattern.
     */
    invalidatePattern(pattern: string | RegExp): number;
}
/**
 * Cache for player data with player-specific invalidation.
 */
export declare class PlayerDataCache extends LRUCache<unknown> {
    private playerKeys;
    /**
     * Cache data for a specific player.
     */
    setPlayerData<T>(playerId: string, dataType: string, data: T): this;
    /**
     * Get cached data for a specific player.
     */
    getPlayerData<T>(playerId: string, dataType: string): T | undefined;
    /**
     * Invalidate all cached data for a player.
     */
    invalidatePlayer(playerId: string): number;
    /**
     * Invalidate specific data type for a player.
     */
    invalidatePlayerData(playerId: string, dataType: string): boolean;
}
/**
 * Get the global query cache instance.
 *
 * @param options - Cache options (only used on first call)
 */
export declare function getQueryCache(options?: CacheOptions): QueryCache;
/**
 * Get the global player data cache instance.
 *
 * @param options - Cache options (only used on first call)
 */
export declare function getPlayerDataCache(options?: CacheOptions): PlayerDataCache;
/**
 * Get the global general-purpose cache instance.
 *
 * @param options - Cache options (only used on first call)
 */
export declare function getGeneralCache(options?: CacheOptions): LRUCache;
/**
 * Create a memoized version of an async function using the cache.
 *
 * @param fn - Function to memoize
 * @param keyFn - Function to generate cache key from arguments
 * @param cache - Cache instance to use (defaults to general cache)
 * @returns Memoized function
 */
export declare function memoize<Args extends unknown[], R>(fn: (...args: Args) => Promise<R>, keyFn: (...args: Args) => string, cache?: LRUCache<R>): (...args: Args) => Promise<R>;
/**
 * Create a memoized version of a sync function using the cache.
 *
 * @param fn - Function to memoize
 * @param keyFn - Function to generate cache key from arguments
 * @param cache - Cache instance to use (defaults to general cache)
 * @returns Memoized function
 */
export declare function memoizeSync<Args extends unknown[], R>(fn: (...args: Args) => R, keyFn: (...args: Args) => string, cache?: LRUCache<R>): (...args: Args) => R;
/**
 * Clear all global cache instances.
 */
export declare function clearAllCaches(): void;
/**
 * Get statistics for all global caches.
 */
export declare function getAllCacheStats(): Record<string, CacheStats>;
/**
 * Log cache statistics to console.
 */
export declare function logCacheStats(): void;
export declare const cacheService: {
    LRUCache: typeof LRUCache;
    QueryCache: typeof QueryCache;
    PlayerDataCache: typeof PlayerDataCache;
    getQueryCache: typeof getQueryCache;
    getPlayerDataCache: typeof getPlayerDataCache;
    getGeneralCache: typeof getGeneralCache;
    memoize: typeof memoize;
    memoizeSync: typeof memoizeSync;
    clearAllCaches: typeof clearAllCaches;
    getAllCacheStats: typeof getAllCacheStats;
    logCacheStats: typeof logCacheStats;
};
//# sourceMappingURL=cache.d.ts.map