function clearMemoized () { const old = {} MEMOIZED.forEach((v, k) => { old[k] = v }) MEMOIZED.reset() return old }
/** * Get all entries in cache. * * @param {Function} fn * @public */ getAll(fn = noop) { const entries = [] this.client.forEach((value, key, cache) => { entries.push({ key: key, value: JSON.parse(value.value) }) }) fn(null, entries) }
/** * Remove all cached entries that match the pattern * * @param {String} pattern * @param {Function} fn */ removeByPattern(pattern, fn = noop) { let total = this.client.itemCount, count = 0 this.client.forEach((value, key) => { if (key.match(pattern)) { this.remove(key, (e) => { if (e) return fn(e) }) } if (++count === total) { fn(null) } }) }