Class ChildrenCacheInternal

an LRUCache for storing child entries.

Hierarchy

Constructors

Properties

#private: any
allowStale: boolean

LRUCache.OptionsBase.allowStale

allowStaleOnFetchAbort: boolean

LRUCache.OptionsBase.allowStaleOnFetchAbort

allowStaleOnFetchRejection: boolean

LRUCache.OptionsBase.allowStaleOnFetchRejection

ignoreFetchAbort: boolean

LRUCache.OptionsBase.ignoreFetchAbort

maxEntrySize: number

LRUCache.OptionsBase.maxEntrySize

noDeleteOnFetchRejection: boolean

LRUCache.OptionsBase.noDeleteOnFetchRejection

noDeleteOnStaleGet: boolean

LRUCache.OptionsBase.noDeleteOnStaleGet

noDisposeOnSet: boolean

LRUCache.OptionsBase.noDisposeOnSet

noUpdateTTL: boolean

LRUCache.OptionsBase.noUpdateTTL

sizeCalculation?: SizeCalculator<PathBase, Children>

LRUCache.OptionsBase.sizeCalculation

ttl: number

LRUCache.OptionsBase.ttl

ttlAutopurge: boolean

LRUCache.OptionsBase.ttlAutopurge

ttlResolution: number

LRUCache.OptionsBase.ttlResolution

updateAgeOnGet: boolean

LRUCache.OptionsBase.updateAgeOnGet

updateAgeOnHas: boolean

LRUCache.OptionsBase.updateAgeOnHas

Accessors

  • get calculatedSize(): number
  • The total computed size of items in the cache (read-only)

    Returns number

  • get dispose(): undefined | Disposer<K, V>
  • LRUCache.OptionsBase.dispose (read-only)

    Returns undefined | Disposer<K, V>

  • get disposeAfter(): undefined | Disposer<K, V>
  • LRUCache.OptionsBase.disposeAfter (read-only)

    Returns undefined | Disposer<K, V>

  • get fetchMethod(): undefined | Fetcher<K, V, FC>
  • LRUCache.OptionsBase.fetchMethod (read-only)

    Returns undefined | Fetcher<K, V, FC>

  • get max(): number
  • LRUCache.OptionsBase.max (read-only)

    Returns number

  • get maxSize(): number
  • LRUCache.OptionsBase.maxSize (read-only)

    Returns number

  • get size(): number
  • The number of items stored in the cache (read-only)

    Returns number

Methods

  • Iterating over the cache itself yields the same results as LRUCache.entries

    Returns Generator<(undefined | PathBase | Children | BackgroundFetch<Children>)[], void, unknown>

  • Clear the cache entirely, throwing away all values.

    Returns void

  • Deletes a key out of the cache. Returns true if the key was deleted, false otherwise.

    Parameters

    Returns boolean

  • Return an array of [key, LRUCache.Entry] tuples which can be passed to cache.load()

    Returns [PathBase, Entry<Children>][]

  • Return a generator yielding [key, value] pairs, in order from most recently used to least recently used.

    Returns Generator<(undefined | PathBase | Children | BackgroundFetch<Children>)[], void, unknown>

  • 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.

    Parameters

    Returns Promise<void | Children>

  • Parameters

    Returns Promise<void | Children>

  • 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.

    Parameters

    Returns void

  • 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.

    Parameters

    Returns undefined | Children

  • Return the remaining TTL time for a given entry key

    Parameters

    Returns number

  • 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.

    Parameters

    Returns boolean

  • Return a generator yielding the keys in the cache, in order from most recently used to least recently used.

    Returns Generator<PathBase, void, unknown>

  • 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.

    Parameters

    Returns void

  • 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.

    Parameters

    Returns undefined | Children

  • Evict the least recently used item, returning its value or undefined if cache is empty.

    Returns undefined | Children

  • Delete any stale entries. Returns true if anything was removed, false otherwise.

    Returns boolean

  • Inverse order version of LRUCache.entries

    Return a generator yielding [key, value] pairs, in order from least recently used to most recently used.

    Returns Generator<(undefined | PathBase | Children | BackgroundFetch<Children>)[], void, unknown>

  • 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.

    Returns Generator<PathBase, void, unknown>

  • 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.

    Returns Generator<undefined | Children | BackgroundFetch<Children>, void, unknown>

  • Return a generator yielding the values in the cache, in order from most recently used to least recently used.

    Returns Generator<undefined | Children | BackgroundFetch<Children>, void, unknown>

  • Internal

    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!

    Type Parameters

    • K extends {}

    • V extends {}

    • FC extends unknown = unknown

    Parameters

    • c: LRUCache<K, V, FC>

    Returns {
        backgroundFetch: ((k: K, index: undefined | number, options: FetchOptions<K, V, FC>, context: any) => BackgroundFetch<V>);
        free: StackLike;
        head: Index;
        indexes: ((options?: {
            allowStale: boolean;
        }) => Generator<Index, void, unknown>);
        isBackgroundFetch: ((p: any) => boolean);
        isStale: ((index: undefined | number) => boolean);
        keyList: (undefined | K)[];
        keyMap: Map<K, number>;
        moveToTail: ((index: number) => void);
        next: NumberArray;
        prev: NumberArray;
        rindexes: ((options?: {
            allowStale: boolean;
        }) => Generator<Index, void, unknown>);
        sizes: undefined | ZeroArray;
        starts: undefined | ZeroArray;
        tail: Index;
        ttls: undefined | ZeroArray;
        valList: (undefined | V | BackgroundFetch<V>)[];
    }

    • backgroundFetch: ((k: K, index: undefined | number, options: FetchOptions<K, V, FC>, context: any) => BackgroundFetch<V>)
        • (k: K, index: undefined | number, options: FetchOptions<K, V, FC>, context: any): BackgroundFetch<V>
        • Parameters

          • k: K
          • index: undefined | number
          • options: FetchOptions<K, V, FC>
          • context: any

          Returns BackgroundFetch<V>

    • free: StackLike
    • Readonly head: Index
    • indexes: ((options?: {
          allowStale: boolean;
      }) => Generator<Index, void, unknown>)
        • (options?: {
              allowStale: boolean;
          }): Generator<Index, void, unknown>
        • Parameters

          • Optional options: {
                allowStale: boolean;
            }
            • allowStale: boolean

          Returns Generator<Index, void, unknown>

    • isBackgroundFetch: ((p: any) => boolean)
        • (p: any): boolean
        • Parameters

          • p: any

          Returns boolean

    • isStale: ((index: undefined | number) => boolean)
        • (index: undefined | number): boolean
        • Parameters

          • index: undefined | number

          Returns boolean

    • keyList: (undefined | K)[]
    • keyMap: Map<K, number>
    • moveToTail: ((index: number) => void)
        • (index: number): void
        • Parameters

          • index: number

          Returns void

    • next: NumberArray
    • prev: NumberArray
    • rindexes: ((options?: {
          allowStale: boolean;
      }) => Generator<Index, void, unknown>)
        • (options?: {
              allowStale: boolean;
          }): Generator<Index, void, unknown>
        • Parameters

          • Optional options: {
                allowStale: boolean;
            }
            • allowStale: boolean

          Returns Generator<Index, void, unknown>

    • sizes: undefined | ZeroArray
    • starts: undefined | ZeroArray
    • Readonly tail: Index
    • ttls: undefined | ZeroArray
    • valList: (undefined | V | BackgroundFetch<V>)[]

Generated using TypeDoc