* @param {string} key * @returns {*}
(key)
| 88 | * @returns {*} |
| 89 | */ |
| 90 | get(key) { |
| 91 | key = String(key) |
| 92 | // Returns the value for the input key. Returns null if key is not present in cache |
| 93 | if (this.cache.has(key)) { |
| 94 | const value = this.cache.get(key) |
| 95 | |
| 96 | // refresh the cache to update the order of key |
| 97 | this.cache.delete(key) |
| 98 | this.cache.set(key, value) |
| 99 | |
| 100 | this.hits++ |
| 101 | return value |
| 102 | } |
| 103 | |
| 104 | this.misses++ |
| 105 | return null |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * @param {JSON} json |
no test coverage detected