Hierarchy

  • CacheOptions

Properties

cacheExceptions?: boolean

When true promise rejections and errors thrown by the cached function will also be cached instead of re-executing.

deepClone?: boolean

Deep clone the object returned by this method using JSON stringify/parse. If the object is a class all prototyped context is lost.

Default

false
immutable?: boolean

The result return by the original function will be immutable. This calls object.freeze which will prevent the returned value from being altered in anyway; this also prevents the object from modifying itself. Only use this when the both the current method nor the callers can change the object.

Default

false
scope?: "global" | "instance"

Scope of the cache, defaults to instance for non-static members and global for static methods

Default

'instance'
ttl?: number

Cache lifetime in seconds. Undefined, 0 or -1 are considered infinite or until the instance is removed When not set the cached value will never expire.

unwrapPromise?: boolean

When true and the result of a function is a Promise<T> cache hits will return the value (of type T) that the promise resolved to instead of the resolved promise. This benefits ES6 async-await code by avoiding yielding control back to the event loop but is incompatible with classic Promisees where .then or .catch is used as the unwrapped value will not implement these values.

Default

false