* Returns the cached value by its key. * Time complexity: O(1) in average. * @param {string} key * @returns {any}
(key)
| 48 | * @returns {any} |
| 49 | */ |
| 50 | get(key) { |
| 51 | if (this.nodesMap[key] === undefined) return undefined; |
| 52 | const node = this.nodesMap[key]; |
| 53 | this.promote(node); |
| 54 | return node.val; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Sets the value to cache by its key. |
no test coverage detected