* Sets a value in cache
(key: string, value: T, customTTL?: number)
| 90 | * Sets a value in cache |
| 91 | */ |
| 92 | set(key: string, value: T, customTTL?: number): void { |
| 93 | // Check size limit and evict if necessary |
| 94 | if (this.cache.size >= this.options.maxSize) { |
| 95 | this.evictLeastRecentlyUsed(); |
| 96 | } |
| 97 | |
| 98 | const now = Date.now(); |
| 99 | const entry: CacheEntry<T> = { |
| 100 | data: value, |
| 101 | timestamp: now, |
| 102 | lastAccessed: now, |
| 103 | accessCount: 1, |
| 104 | }; |
| 105 | |
| 106 | this.cache.set(key, entry); |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Checks if a key exists in cache (without updating access stats) |
no test coverage detected