Options
All
  • Public
  • Public/Protected
  • All
Menu

Representation of a cache to transiently store objects locally for faster access.

Type parameters

  • T

    Type of the cache entries.

Hierarchy

  • Cache

Implements

  • CacheInterface<T>

Index

Constructors

Methods

Constructors

constructor

  • new Cache<T>(validityTime?: MomentInputObject): Cache<T>
  • Type parameters

    • T

    Parameters

    • Optional validityTime: MomentInputObject

    Returns Cache<T>

Methods

clear

  • clear(): void
  • Clear all cached items.

    Returns void

get

  • get(key: string): undefined | T
  • Getter of cached entries.

    Parameters

    • key: string

      The key of the entry to retrieve

    Returns undefined | T

    The corresponding entry to the provided key if it is still valid, returns undefined otherwise

hasKey

  • hasKey(key: string): boolean
  • Specifies whether an entry with a given key is defined in cache.

    Parameters

    • key: string

      The entry's key

    Returns boolean

    boolean A boolean value that indicates whether the entry exists in cache

set

  • set(key: string, entry: T, expirationTime?: number): void
  • Setter of entries in cache.

    Parameters

    • key: string

      The entry's key

    • entry: T

      The entry to cache

    • Optional expirationTime: number

      The time expressed in UTC in which the given entry expires

    Returns void