(key: string, data: T)
| 18 | } |
| 19 | |
| 20 | set(key: string, data: T): void { |
| 21 | this.cache.set(key, { data, fetchedAt: Date.now() }); |
| 22 | if (this.cache.size > this.maxEntries) { |
| 23 | const now = Date.now(); |
| 24 | for (const [k, v] of this.cache) { |
| 25 | if (now - v.fetchedAt > this.ttl) this.cache.delete(k); |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | /** Single-value in-memory cache with TTL. */ |
no outgoing calls
no test coverage detected