Socket
Socket
Sign inDemoInstall

lru-cache

Package Overview
Dependencies
0
Maintainers
1
Versions
135
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.12.1 to 7.13.0

5

index.d.ts

@@ -572,6 +572,7 @@ // Type definitions for lru-cache 7.10.0

* 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<K, V> extends FetcherFetchOptions<K, V> {
forceRefresh?: boolean
fetchContext?: any

@@ -578,0 +579,0 @@ }

17

index.js

@@ -528,3 +528,5 @@ const perf =

const v = this.valList[i]
const value = this.isBackgroundFetch(v) ? v.__staleWhileFetching : v
const value = this.isBackgroundFetch(v)
? v.__staleWhileFetching
: v
const entry = { value }

@@ -773,6 +775,11 @@ if (this.ttls) {

fetchContext = this.fetchContext,
forceRefresh = false,
} = {}
) {
if (!this.fetchMethod) {
return this.get(k, { allowStale, updateAgeOnGet, noDeleteOnStaleGet })
return this.get(k, {
allowStale,
updateAgeOnGet,
noDeleteOnStaleGet,
})
}

@@ -805,3 +812,5 @@

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)

@@ -814,3 +823,3 @@ if (updateAgeOnGet) {

// ok, it is stale, and not already fetching
// ok, it is stale or a forced refresh, and not already fetching.
// refresh the cache.

@@ -817,0 +826,0 @@ const p = this.backgroundFetch(k, index, options, fetchContext)

{
"name": "lru-cache",
"description": "A cache object that deletes the least-recently-used items.",
"version": "7.12.1",
"version": "7.13.0",
"author": "Isaac Z. Schlueter <i@izs.me>",

@@ -6,0 +6,0 @@ "keywords": [

@@ -465,3 +465,3 @@ # lru-cache

### `async fetch(key, { updateAgeOnGet, allowStale, size,
sizeCalculation, ttl, noDisposeOnSet } = {}) => Promise`
sizeCalculation, ttl, noDisposeOnSet, forceRefresh } = {}) => Promise`

@@ -479,2 +479,9 @@ If the value is in the cache and not stale, then the returned

If called with `forceRefresh`, then the cached item will be
re-fetched, even if it is not stale. However, if `allowStale` is
set, then the old value will still be returned. This is useful
in cases where you want to force a reload of a cached value. If
a background fetch is already in progress, then `forceRefresh`
has no effect.
Multiple fetches for the same `key` will only call `fetchMethod`

@@ -481,0 +488,0 @@ a single time, and all will be resolved when the value is

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc