Interface LRUCacheSetEntryOptions<TKey, TValue>

Type Parameters

  • TKey

  • TValue

Hierarchy

  • LRUCacheSetEntryOptions

Properties

clone?: boolean

Clone values being set and fetched from the cache (clones on set and any retrievals). Useful to maintain immutability. NOTE! This does come with performance overhead (almost twice as slow). Defaults to false.

cloneFn?: ((value: TValue) => TValue)

Type declaration

    • (value: TValue): TValue
    • Custom function to be used with the clone option. If not passed, JSON.parse(JSON.stringify(value)) is used for cloning objects.

      Parameters

      • value: TValue

      Returns TValue

entryExpirationTimeInMS?: null | number

The time to live for this cache entry. Setting this to null will make entry never expire. Default value is null.

onEntryEvicted?: ((evictedEntry: { isExpired: boolean; key: TKey; value: TValue }) => void)

Type declaration

    • (evictedEntry: { isExpired: boolean; key: TKey; value: TValue }): void
    • Function to be called whenever this entry is evicted from the cache (when evicted due to needing to make room, is expired, or deleted using delete()). Passed argument is an object:

       {
      key: TKey;
      value: TValue;
      isExpired: boolean;
      }

      Parameters

      • evictedEntry: { isExpired: boolean; key: TKey; value: TValue }
        • isExpired: boolean
        • key: TKey
        • value: TValue

      Returns void

onEntryMarkedAsMostRecentlyUsed?: ((entry: { key: TKey; value: TValue }) => void)

Type declaration

    • (entry: { key: TKey; value: TValue }): void
    • Function to be called whenever this entry is marked as recently used (on set, get, find, etc). Passed argument is an object:

       {
      key: TKey;
      value: TValue;
      }

      Parameters

      • entry: { key: TKey; value: TValue }
        • key: TKey
        • value: TValue

      Returns void

Generated using TypeDoc