diff --git a/node_modules/lru-cache/index.d.ts b/node_modules/lru-cache/index.d.ts
index b9375a8b96a71..e5481b3f92637 100644
--- a/node_modules/lru-cache/index.d.ts
+++ b/node_modules/lru-cache/index.d.ts
@@ -1,4 +1,3 @@
-// Type definitions for lru-cache 7.10.0
// Project: https://github.com/isaacs/node-lru-cache
// Based initially on @types/lru-cache
// https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -32,7 +31,6 @@
// Changes by Isaac Z. Schlueter released under the terms found in the
// LICENSE file within this project.
-///
//tslint:disable:member-access
declare class LRUCache implements Iterable<[K, V]> {
constructor(options: LRUCache.Options)
@@ -569,10 +567,11 @@ declare namespace LRUCache {
/**
* options which override the options set in the LRUCache constructor
* when making `cache.fetch()` calls.
- * This is the union of GetOptions and SetOptions, plus the
- * `noDeleteOnFetchRejection` and `fetchContext` fields.
+ * This is the union of GetOptions and SetOptions, plus
+ * `noDeleteOnFetchRejection`, `forceRefresh`, and `fetchContext`
*/
interface FetchOptions extends FetcherFetchOptions {
+ forceRefresh?: boolean
fetchContext?: any
}
diff --git a/node_modules/lru-cache/index.js b/node_modules/lru-cache/index.js
index 479ffc8656b70..0a551c9d1d6f2 100644
--- a/node_modules/lru-cache/index.js
+++ b/node_modules/lru-cache/index.js
@@ -364,8 +364,10 @@ class LRUCache {
initializeSizeTracking() {
this.calculatedSize = 0
this.sizes = new ZeroArray(this.max)
- this.removeItemSize = index =>
- (this.calculatedSize -= this.sizes[index])
+ this.removeItemSize = index => {
+ this.calculatedSize -= this.sizes[index]
+ this.sizes[index] = 0
+ }
this.requireSize = (k, v, size, sizeCalculation) => {
if (!isPosInt(size)) {
if (sizeCalculation) {
@@ -386,7 +388,7 @@ class LRUCache {
}
return size
}
- this.addItemSize = (index, v, k, size) => {
+ this.addItemSize = (index, size) => {
this.sizes[index] = size
const maxSize = this.maxSize - this.sizes[index]
while (this.calculatedSize > maxSize) {
@@ -396,7 +398,7 @@ class LRUCache {
}
}
removeItemSize(index) {}
- addItemSize(index, v, k, size) {}
+ addItemSize(index, size) {}
requireSize(k, v, size, sizeCalculation) {
if (size || sizeCalculation) {
throw new TypeError(
@@ -523,7 +525,9 @@ class LRUCache {
for (const i of this.indexes({ allowStale: true })) {
const key = this.keyList[i]
const v = this.valList[i]
- const value = this.isBackgroundFetch(v) ? v.__staleWhileFetching : v
+ const value = this.isBackgroundFetch(v)
+ ? v.__staleWhileFetching
+ : v
const entry = { value }
if (this.ttls) {
entry.ttl = this.ttls[i]
@@ -569,6 +573,10 @@ class LRUCache {
} = {}
) {
size = this.requireSize(k, v, size, sizeCalculation)
+ // if the item doesn't fit, don't do anything
+ if (this.maxSize && size > this.maxSize) {
+ return this
+ }
let index = this.size === 0 ? undefined : this.keyMap.get(k)
if (index === undefined) {
// addition
@@ -580,7 +588,7 @@ class LRUCache {
this.prev[index] = this.tail
this.tail = index
this.size++
- this.addItemSize(index, v, k, size)
+ this.addItemSize(index, size)
noUpdateTTL = false
} else {
// update
@@ -598,7 +606,7 @@ class LRUCache {
}
this.removeItemSize(index)
this.valList[index] = v
- this.addItemSize(index, v, k, size)
+ this.addItemSize(index, size)
}
this.moveToTail(index)
}
@@ -680,7 +688,9 @@ class LRUCache {
peek(k, { allowStale = this.allowStale } = {}) {
const index = this.keyMap.get(k)
if (index !== undefined && (allowStale || !this.isStale(index))) {
- return this.valList[index]
+ const v = this.valList[index]
+ // either stale and allowed, or forcing a refresh of non-stale value
+ return this.isBackgroundFetch(v) ? v.__staleWhileFetching : v
}
}
@@ -763,10 +773,15 @@ class LRUCache {
// fetch exclusive options
noDeleteOnFetchRejection = this.noDeleteOnFetchRejection,
fetchContext = this.fetchContext,
+ forceRefresh = false,
} = {}
) {
if (!this.fetchMethod) {
- return this.get(k, { allowStale, updateAgeOnGet, noDeleteOnStaleGet })
+ return this.get(k, {
+ allowStale,
+ updateAgeOnGet,
+ noDeleteOnStaleGet,
+ })
}
const options = {
@@ -794,7 +809,9 @@ class LRUCache {
: (v.__returned = v)
}
- if (!this.isStale(index)) {
+ // if we force a refresh, that means do NOT serve the cached value,
+ // unless we are already in the process of refreshing the cache.
+ if (!forceRefresh && !this.isStale(index)) {
this.moveToTail(index)
if (updateAgeOnGet) {
this.updateItemAge(index)
@@ -802,7 +819,7 @@ class LRUCache {
return v
}
- // ok, it is stale, and not already fetching
+ // ok, it is stale or a forced refresh, and not already fetching.
// refresh the cache.
const p = this.backgroundFetch(k, index, options, fetchContext)
return allowStale && p.__staleWhileFetching !== undefined
diff --git a/node_modules/lru-cache/package.json b/node_modules/lru-cache/package.json
index c023ce6c49aca..c3c62e0a3254e 100644
--- a/node_modules/lru-cache/package.json
+++ b/node_modules/lru-cache/package.json
@@ -1,13 +1,14 @@
{
"name": "lru-cache",
"description": "A cache object that deletes the least-recently-used items.",
- "version": "7.12.0",
+ "version": "7.13.2",
"author": "Isaac Z. Schlueter ",
"keywords": [
"mru",
"lru",
"cache"
],
+ "sideEffects": false,
"scripts": {
"build": "",
"size": "size-limit",
@@ -26,7 +27,7 @@
"@types/tap": "^15.0.6",
"benchmark": "^2.1.4",
"c8": "^7.11.2",
- "clock-mock": "^1.0.4",
+ "clock-mock": "^1.0.6",
"eslint-config-prettier": "^8.5.0",
"prettier": "^2.6.2",
"size-limit": "^7.0.8",
diff --git a/package-lock.json b/package-lock.json
index ffcdc16be1969..def6d84a38a2d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4598,9 +4598,9 @@
}
},
"node_modules/lru-cache": {
- "version": "7.12.0",
- "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.12.0.tgz",
- "integrity": "sha512-OIP3DwzRZDfLg9B9VP/huWBlpvbkmbfiBy8xmsXp4RPmE4A3MhwNozc5ZJ3fWnSg8fDcdlE/neRTPG2ycEKliw==",
+ "version": "7.13.2",
+ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.13.2.tgz",
+ "integrity": "sha512-VJL3nIpA79TodY/ctmZEfhASgqekbT574/c4j3jn4bKXbSCnTTCH/KltZyvL2GlV+tGSMtsWyem8DCX7qKTMBA==",
"inBundle": true,
"engines": {
"node": ">=12"