* Put the entry into the cache. If the key already existed, mark the key as * used recently.
(key: string, value: T)
| 40 | * used recently. |
| 41 | */ |
| 42 | public put(key: string, value: T): void { |
| 43 | if (this.cache.has(key)) { |
| 44 | this.cache.delete(key); |
| 45 | } else if (this.cache.size >= this.maxEntries) { |
| 46 | const keyToDelete = this.cache.keys().next().value; |
| 47 | this.cache.delete(keyToDelete); |
| 48 | } |
| 49 | this.cache.set(key, value); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Get the MaxEntries of the cache. |
no test coverage detected