Class ResolveCacheInternal

An LRUCache for storing resolved path strings or Path objects.

Hierarchy

  • LRUCache<string, string>
    • ResolveCache

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<string, string>

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 | string | BackgroundFetch<string>)[], 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

    • k: string

    Returns boolean

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

    Returns [string, Entry<string>][]

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

    Returns Generator<(undefined | string | BackgroundFetch<string>)[], 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

    • k: string
    • fetchOptions: FetchOptions<string, string, unknown>

    Returns Promise<string | void>

  • Parameters

    • k: string
    • Optional fetchOptions: FetchOptions<string, string, unknown>

    Returns Promise<string | void>

  • Find a value for which the supplied fn method returns a truthy value, similar to Array.find(). fn is called as fn(value, key, cache).

    Parameters

    • fn: ((v: string, k: string, self: LRUCache<string, string, unknown>) => boolean)
        • (v: string, k: string, self: LRUCache<string, string, unknown>): boolean
        • Parameters

          • v: string
          • k: string
          • self: LRUCache<string, string, unknown>

          Returns boolean

    • Optional getOptions: GetOptions<string, string, unknown>

    Returns undefined | string

  • 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

    • fn: ((v: string, k: string, self: LRUCache<string, string, unknown>) => any)
        • (v: string, k: string, self: LRUCache<string, string, unknown>): any
        • Parameters

          • v: string
          • k: string
          • self: LRUCache<string, string, unknown>

          Returns any

    • Optional thisp: any

    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

    • k: string
    • Optional getOptions: GetOptions<string, string, unknown>

    Returns undefined | string

  • Return the remaining TTL time for a given entry key

    Parameters

    • key: string

    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

    • k: string
    • Optional hasOptions: HasOptions<string, string, unknown>

    Returns boolean

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

    Returns Generator<string, 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

    • arr: [string, Entry<string>][]

    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

    • k: string
    • Optional peekOptions: PeekOptions<string, string, unknown>

    Returns undefined | string

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

    Returns undefined | string

  • 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 | string | BackgroundFetch<string>)[], void, unknown>

  • The same as LRUCache.forEach but items are iterated over in reverse order. (ie, less recently used items are iterated over first.)

    Parameters

    • fn: ((v: string, k: string, self: LRUCache<string, string, unknown>) => any)
        • (v: string, k: string, self: LRUCache<string, string, unknown>): any
        • Parameters

          • v: string
          • k: string
          • self: LRUCache<string, string, unknown>

          Returns any

    • Optional thisp: any

    Returns void

  • 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<string, 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 | string | BackgroundFetch<string>, void, unknown>

  • Add a value to the cache.

    Note: if undefined is specified as a value, this is an alias for LRUCache#delete

    Parameters

    • k: string
    • v: undefined | string | BackgroundFetch<string>
    • Optional setOptions: SetOptions<string, string, unknown>

    Returns ResolveCache

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

    Returns Generator<undefined | string | BackgroundFetch<string>, 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