Class Cache<T>

An abstraction for prioritizing performance over data "freshness"

Type Parameters

  • T

Implements

Constructors

  • Type Parameters

    • T

    Parameters

    • storage: IGenericStorage

      the storage interface used to support caching

    • cacheLife: number | ((entry) => boolean) = 0

      EITHER 1.) the amount of milliseconds after the cache is created till it is invalidated | leaving the default value (0) will result prevent any auto clearing of cache entries OR 2.) a function defining when the cache is no longer valid; a "false" return will invalidate the cache

    • serializer: JsonSerializer = ...

    Returns Cache<T>

Properties

cacheLife: number | ((entry) => boolean) = 0

EITHER 1.) the amount of milliseconds after the cache is created till it is invalidated | leaving the default value (0) will result prevent any auto clearing of cache entries OR 2.) a function defining when the cache is no longer valid; a "false" return will invalidate the cache

Type declaration

    • (entry): boolean
    • Parameters

      • entry: T

      Returns boolean

serializer: JsonSerializer = ...

the storage interface used to support caching

Methods

  • Get the value cached at the given key | returns null when there is no value for the given key

    Parameters

    • key: string
    • Optional type: (new () => T)
        • new (): T
        • Returns T

    Returns null | T

Generated using TypeDoc