* Get an entry from the cache if it exists and is not expired.
(key: string)
| 31 | * Get an entry from the cache if it exists and is not expired. |
| 32 | */ |
| 33 | get(key: string): T | null { |
| 34 | const entry = this.cache.get(key); |
| 35 | if (!entry) return null; |
| 36 | |
| 37 | // Check TTL |
| 38 | if (Date.now() - entry.timestamp > this.config.maxAge) { |
| 39 | this.delete(key); |
| 40 | return null; |
| 41 | } |
| 42 | |
| 43 | // Update access count for LRU |
| 44 | entry.accessCount++; |
| 45 | return entry.data; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Get entry only if hash matches (for conditional updates). |
no test coverage detected