* Cleanup expired entries
()
| 180 | * Cleanup expired entries |
| 181 | */ |
| 182 | cleanup(): number { |
| 183 | let removedCount = 0; |
| 184 | const now = Date.now(); |
| 185 | |
| 186 | for (const [key, entry] of this.cache.entries()) { |
| 187 | if (now - entry.timestamp > this.options.ttl) { |
| 188 | this.cache.delete(key); |
| 189 | removedCount++; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | if (removedCount > 0 && this.options.enableStats) { |
| 194 | this.logger.log(`Cleaned up ${removedCount} expired cache entries`); |
| 195 | } |
| 196 | |
| 197 | return removedCount; |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * Evict least recently used entry |
no test coverage detected