import type { EventEmitter } from 'events'; import type { TTLData } from './types.js'; /** * TTL (Time To Live) Manager * Handles expiration logic for database keys with automatic cleanup */ export declare class TTLManager { /** Map storing key -> expiration timestamp mappings */ private ttlData; /** Event emitter for TTL-related events */ private eventEmitter; /** Interval timer for periodic cleanup */ private cleanupInterval; /** Cleanup interval in milliseconds */ private cleanupIntervalMs; /** * Creates a new TTL manager instance * @param eventEmitter - Optional event emitter for TTL events * @param cleanupIntervalMs - Cleanup interval in milliseconds (default: 60000) */ constructor(eventEmitter?: EventEmitter, cleanupIntervalMs?: number); /** * Set TTL for a key * @param key - The key to set TTL for * @param ttlSeconds - TTL duration in seconds */ setTTL(key: string, ttlSeconds: number): void; /** * Get remaining TTL for a key in seconds * @param key - The key to check TTL for * @returns Remaining TTL in seconds, or null if no TTL set or expired */ getTTL(key: string): number | null; /** * Clear TTL for a key * @param key - The key to clear TTL for * @returns True if TTL was cleared, false if no TTL was set */ clearTTL(key: string): boolean; /** * Check if a key has expired * @param key - The key to check * @returns True if the key has expired, false otherwise */ isExpired(key: string): boolean; /** * Get all expired keys * @returns Array of keys that have expired */ getExpiredKeys(): string[]; /** * Remove expired keys from TTL tracking * @param expiredKeys - Array of expired keys to remove */ removeExpiredKeys(expiredKeys: string[]): void; /** * Get all TTL data for serialization * @returns TTL data object with non-expired keys only */ getAllTTLData(): TTLData; /** * Load TTL data from deserialization * @param ttlData - TTL data to load */ loadTTLData(ttlData: TTLData): void; /** * Start periodic cleanup of expired keys * Runs cleanup at the configured interval */ private startCleanup; /** * Stop periodic cleanup */ stopCleanup(): void; /** * Clear all TTL data */ clear(): void; /** * Get count of keys with TTL * @returns Number of keys currently tracked for TTL */ size(): number; } //# sourceMappingURL=ttl-manager.d.ts.map