(key: K, value: V)
| 51 | } |
| 52 | |
| 53 | set(key: K, value: V): void { |
| 54 | // Remove oldest entry if we're at capacity |
| 55 | if (this.cache.size >= this.maxSize) { |
| 56 | const oldestKey = this.cache.keys().next().value; |
| 57 | this.cache.delete(oldestKey); |
| 58 | } |
| 59 | |
| 60 | this.cache.set(key, { |
| 61 | value, |
| 62 | timestamp: Date.now(), |
| 63 | }); |
| 64 | } |
| 65 | |
| 66 | get(key: K): V | undefined { |
| 67 | const entry = this.cache.get(key); |
no outgoing calls
no test coverage detected