/** * Access Tracker with Count-Min Sketch * Tracks access patterns using memory-efficient probabilistic data structures * Requirements: 3.1, 3.2, 3.4 */ /** * Information about a key's access patterns */ export interface KeyAccessInfo { key: string; accessCount: number; frequency: number; lastAccess: number; } /** * Configuration options for AccessTracker */ export interface AccessTrackerConfig { /** Width of the Count-Min Sketch (number of counters per row) */ sketchWidth?: number; /** Depth of the Count-Min Sketch (number of hash functions) */ sketchDepth?: number; /** Default time window in milliseconds for frequency calculation */ defaultWindowMs?: number; /** Maximum number of keys to track timestamps for */ maxTrackedKeys?: number; } /** * AccessTracker implementation using Count-Min Sketch for memory-efficient * access counting and LRU cache for timestamp tracking. * * Requirements: * - 3.1: Record access timestamp when a key is accessed * - 3.2: Increment access count when a key is accessed * - 3.4: Store access metadata with minimal memory overhead using probabilistic data structures */ export declare class AccessTracker { private readonly sketch; private readonly timestamps; private timeWindowMs; constructor(config?: AccessTrackerConfig); /** * Record an access event for a key. * Updates both the Count-Min Sketch counter and the last access timestamp. * * Requirement 3.1: Record access timestamp * Requirement 3.2: Increment access count */ recordAccess(key: string): void; /** * Get the approximate access count for a key. * Uses Count-Min Sketch which may overestimate but never underestimates. * * Requirement 3.2: Access count tracking */ getAccessCount(key: string): number; /** * Get the access frequency for a key within a time window. * Frequency is calculated as accesses per millisecond, normalized to the window. * * The calculation considers: * 1. If last access was within the window, use count/window as base frequency * 2. If last access was outside the window, decay the frequency based on time elapsed * * Requirement 3.3: Calculate access frequency using sliding time window */ getAccessFrequency(key: string, windowMs: number): number; /** * Get the last access time for a key. * Returns null if the key has never been accessed or was evicted from tracking. * * Requirement 3.1: Record access timestamp */ getLastAccessTime(key: string): number | null; /** * Get the N hottest (most frequently accessed) keys. * Uses a min-heap approach to efficiently find top N keys. * * Requirement 3.5: Support for identifying hot keys */ getHottestKeys(n: number): KeyAccessInfo[]; /** * Set the default time window for frequency calculations. * * Requirement 3.5: Support configurable time windows */ setTimeWindow(windowMs: number): void; /** * Get the current time window setting */ getTimeWindow(): number; /** * Clean up old entries and reset counters if needed. * This can be called periodically to prevent counter overflow * and remove stale timestamp entries. */ cleanup(): void; } //# sourceMappingURL=AccessTracker.d.ts.map