* @method parse * @description - This method receive a valid LFUCache JSON & run JSON.prase() method and merge with existing LFUCache * @param {JSON} json * @returns {LFUCache} - merged
(json)
| 207 | * @returns {LFUCache} - merged |
| 208 | */ |
| 209 | parse(json) { |
| 210 | const { misses, hits, cache } = JSON.parse(json) |
| 211 | |
| 212 | this.misses += misses ?? 0 |
| 213 | this.hits += hits ?? 0 |
| 214 | |
| 215 | for (const key in cache) { |
| 216 | const { value, frequency } = cache[key] |
| 217 | this.set(key, value, frequency) |
| 218 | } |
| 219 | |
| 220 | return this |
| 221 | } |
| 222 | |
| 223 | /** |
| 224 | * @method clear |