Interface SetOptions<K, V, FC>

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

Type Parameters

  • K

  • V

  • FC

Hierarchy

  • Pick<OptionsBase<K, V, FC>, "sizeCalculation" | "ttl" | "noDisposeOnSet" | "noUpdateTTL">
    • SetOptions

Properties

noDisposeOnSet?: boolean

Set to true to suppress calling the OptionsBase.dispose function if the entry key is still accessible within the cache. This may be overridden by passing an options object to LRUCache#set.

noUpdateTTL?: boolean

Boolean flag to tell the cache to not update the TTL when setting a new value for an existing key (ie, when updating a value rather than inserting a new value). Note that the TTL value is always set (if provided) when adding a new entry into the cache.

Has no effect if a OptionsBase.ttl is not set.

size?: number

If size tracking is enabled, then setting an explicit size in the LRUCache#set call will prevent calling the OptionsBase.sizeCalculation function.

sizeCalculation?: SizeCalculator<K, V>

A function that returns a number indicating the item's size.

If not provided, and OptionsBase.maxSize or OptionsBase.maxEntrySize are set, then all LRUCache#set calls must provide an explicit SetOptions.size or sizeCalculation param.

start?: number

If TTL tracking is enabled, then setting an explicit start time in the LRUCache#set call will override the default time from performance.now() or Date.now().

Note that it must be a valid value for whichever time-tracking method is in use.

status?: Status<V>
ttl?: number

Max time in milliseconds for items to live in cache before they are considered stale. Note that stale items are NOT preemptively removed by default, and MAY live in the cache long after they have expired.

Also, as this cache is optimized for LRU/MRU operations, some of the staleness/TTL checks will reduce performance, as they will incur overhead by deleting items.

Must be an integer number of ms. If set to 0, this indicates "no TTL"

Default

0

Generated using TypeDoc