* Get cached response if available and not expired.
(key: string)
| 167 | * Get cached response if available and not expired. |
| 168 | */ |
| 169 | get(key: string): CachedLLMResponse | undefined { |
| 170 | const entry = this.cache.get(key); |
| 171 | if (!entry) { |
| 172 | this.stats.misses++; |
| 173 | return undefined; |
| 174 | } |
| 175 | |
| 176 | // Check expiration |
| 177 | if (Date.now() > entry.expiresAt) { |
| 178 | this.cache.delete(key); |
| 179 | this.stats.misses++; |
| 180 | return undefined; |
| 181 | } |
| 182 | |
| 183 | this.stats.hits++; |
| 184 | return entry; |
| 185 | } |
| 186 | |
| 187 | /** |
| 188 | * Cache a response with optional custom TTL. |
no outgoing calls
no test coverage detected