MCPcopy
hub / github.com/TheAlgorithms/JavaScript / get

Method get

Cache/LFUCache.js:150–164  ·  view source on GitHub ↗

* @method get * @description - This method return the value of key & refresh the frequencyMap by the oldNode * @param {string} key * @returns {any}

(key)

Source from the content-addressed store, hash-verified

148 * @returns {any}
149 */
150 get(key) {
151 key = String(key) // converted to string
152
153 if (this.cache.has(key)) {
154 const oldNode = this.cache.get(key)
155 this.#frequencyMap.refresh(oldNode)
156
157 this.hits++
158
159 return oldNode.value
160 }
161
162 this.misses++
163 return null
164 }
165
166 /**
167 * @method set

Callers 5

refreshMethod · 0.45
insertMethod · 0.45
leastFrequencyMethod · 0.45
#removeCacheNodeMethod · 0.45
setMethod · 0.45

Calls 2

refreshMethod · 0.80
hasMethod · 0.45

Tested by

no test coverage detected