Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Cache<TKey, TValue>

A temporary key-value storage for reusable data. Data in a cache is preserved for an indeterminate amount of time, but may be evicted at any time.

Type parameters

  • TKey

  • TValue

Hierarchy

  • Cache

Index

Methods

clear

  • clear(): void
  • Removes all data stored in the cache. If the cache has any internal state, then it must be fully reset as well.

    Returns void

get

  • get(key: TKey): TValue
  • Retrieves the cached data associated with a key. Throws an exception if no data is stored. Use has to safely check if a specific key is cached.

    throws

    If there is no value stored for key

    Parameters

    • key: TKey

      Key to test

    Returns TValue

has

  • has(key: TKey): boolean
  • Checks if the cache contains a mapping for a specified key.

    Parameters

    • key: TKey

      Key to test

    Returns boolean

remove

  • remove(key: TKey): void
  • Removes the value associated with a key. The key itself is also forgotten, meaning that a call to has after calling remove will return false.

    Parameters

    • key: TKey

      Key to remove

    Returns void

store

  • store(key: TKey, value: TValue): void
  • Associates value to key in the cache. If there is already a value stored for key, then it is overwritten.

    Parameters

    • key: TKey

      Key to index

    • value: TValue

      Value to associate

    Returns void

Generated using TypeDoc