Interface PeekOptions<K, V, FC>

Options that may be passed to the LRUCache#peek method.

interface PeekOptions<K, V, FC> {
    allowStale?: boolean;
}

Type Parameters

  • K
  • V
  • FC

Hierarchy

Properties

Properties

allowStale?: boolean

Allow LRUCache#get and LRUCache#fetch calls to return stale data, if available.

By default, if you set ttl, stale items will only be deleted from the cache when you get(key). That is, it's not preemptively pruning items, unless OptionsBase.ttlAutopurge is set.

If you set allowStale:true, it'll return the stale value as well as deleting it. If you don't set this, then it'll return undefined when you try to get a stale entry.

Note that when a stale entry is fetched, even if it is returned due to allowStale being set, it is removed from the cache immediately. You can suppress this behavior by setting OptionsBase.noDeleteOnStaleGet, either in the constructor, or in the options provided to LRUCache#get.

This may be overridden by passing an options object to cache.get(). The cache.has() method will always return false for stale items.

Only relevant if a ttl is set.