tsbase
    Preparing search index...

    Class Cache<T>

    An abstraction for prioritizing performance over data "freshness"

    Type Parameters

    • T

    Implements

    Index

    Constructors

    Methods

    Constructors

    • Type Parameters

      • T

      Parameters

      • storage: IGenericStorage

        the storage interface used to support caching

      • cacheLife: number | ((entry: T) => 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>

    Methods

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

      Parameters

      • key: string
      • Optionaltype: new () => T

      Returns null | T