Private
#addPrivate
#calculatedPrivate
Optional
Readonly
#disposePrivate
Optional
Readonly
#disposePrivate
Optional
#disposedPrivate
Optional
Readonly
#fetchPrivate
#freePrivate
#hasPrivate
#hasPrivate
#hasPrivate
#headPrivate
#isPrivate
#keyPrivate
#keyPrivate
Readonly
#maxPrivate
Readonly
#maxPrivate
#nextPrivate
#prevPrivate
#removePrivate
#requireOptional
size: numberOptional
sizeCalculation: SizeCalculator<K, V>Private
#setOptional
start: numberPrivate
#sizePrivate
Optional
#sizesPrivate
Optional
#startsPrivate
#statusTTLPrivate
#tailPrivate
Optional
#ttlsPrivate
#updatePrivate
#valA String value that is used in the creation of the default string description of an object. Called by the built-in method Object.prototype.toString.
Optional
sizeThe total computed size of items in the cache (read-only)
LRUCache.OptionsBase.dispose (read-only)
LRUCache.OptionsBase.disposeAfter (read-only)
LRUCache.OptionsBase.fetchMethod (read-only)
LRUCache.OptionsBase.max (read-only)
LRUCache.OptionsBase.maxSize (read-only)
The number of items stored in the cache (read-only)
Private
#backgroundPrivate
#connectPrivate
#evictPrivate
#indexesPrivate
#initializePrivate
#initializeTTLTrackingPrivate
#isPrivate
#isPrivate
#movePrivate
#rindexesIterating over the cache itself yields the same results as LRUCache.entries
Return an array of [key, LRUCache.Entry] tuples which can be passed to cache.load()
Make an asynchronous cached fetch using the LRUCache.OptionsBase.fetchMethod function.
If multiple fetches for the same key are issued, then they will all be coalesced into a single call to fetchMethod.
Note that this means that handling options such as LRUCache.OptionsBase.allowStaleOnFetchAbort, LRUCache.FetchOptions.signal, and LRUCache.OptionsBase.allowStaleOnFetchRejection will be determined by the FIRST fetch() call for a given key.
This is a known (fixable) shortcoming which will be addresed on when someone complains about it, as the fix would involve added complexity and may not be worth the costs for this edge case.
Optional
fetchOptions: unknown extends FCFind a value for which the supplied fn method returns a truthy value, similar to Array.find(). fn is called as fn(value, key, cache).
Call the supplied function on each item in the cache, in order from most recently used to least recently used. fn is called as fn(value, key, cache). Does not update age or recenty of use. Does not iterate over stale values.
Return a value from the cache. Will update the recency of the cache entry found.
If the key is not found, get() will return undefined
.
Check if a key is in the cache, without updating the recency of use. Will return false if the item is stale, even though it is technically in the cache.
Will not update item age unless LRUCache.OptionsBase.updateAgeOnHas is set.
Get the extended info about a given entry, to get its value, size, and TTL info simultaneously. Like LRUCache#dump, but just for a single key. Always returns stale values, if their info is found in the cache, so be sure to check for expired TTLs if relevant.
Reset the cache and load in the items in entries in the order listed. Note that the shape of the resulting cache may be different if the same options are not used in both caches.
Like LRUCache#get but doesn't update recency or delete stale items.
Returns undefined
if the item is stale, unless
LRUCache.OptionsBase.allowStale is set.
Inverse order version of LRUCache.entries
Return a generator yielding [key, value]
pairs,
in order from least recently used to most recently used.
The same as LRUCache.forEach but items are iterated over in reverse order. (ie, less recently used items are iterated over first.)
Inverse order version of LRUCache.keys
Return a generator yielding the keys in the cache, in order from least recently used to most recently used.
Inverse order version of LRUCache.values
Return a generator yielding the values in the cache, in order from least recently used to most recently used.
Add a value to the cache.
Note: if undefined
is specified as a value, this is an alias for
LRUCache#delete
Static
unsafeInternal
Do not call this method unless you need to inspect the inner workings of the cache. If anything returned by this object is modified in any way, strange breakage may occur.
These fields are private for a reason!
Generated using TypeDoc
Default export, the thing you're using this module to get.
All properties from the options object (with the exception of OptionsBase.max and OptionsBase.maxSize) are added as normal public members. (
max
andmaxBase
are read-only getters.) Changing any of these will alter the defaults for subsequent method calls, but is otherwise safe.