Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface CacheBackend<Key, Value>

Represents an abstraction over the cache storage.

Type parameters

  • Key

    Type of the key.

  • Value

    Type of the value.

Hierarchy

Implemented by

Properties

Readonly size

size: number

Number of stored entries.

Methods

[Symbol.iterator]

  • [Symbol.iterator](): IterableIterator<[Key, CacheEntry<Key, Value>]>

clear

  • clear(): void
  • Remove all entries from storage.

    Returns void

del

  • Delete entry.

    Parameters

    • entry: CacheEntry<Key, Value>

      Entry that needs to be deleted.

    Returns void

get

  • get(key: Key): undefined | CacheEntry<Key, Value>

has

  • has(key: Key): boolean
  • Check if key is present in the cache.

    Parameters

    • key: Key

      Name of the key.

    Returns boolean

keys

  • keys(): IterableIterator<Key>

set

  • set(key: Key, value: Value): CacheEntry<Key, Value>
  • Store key with value.

                            ⚠️ WARNING ⚠️
    

    This method should not be used to overwrite value of the key!
    You need to query the entry first and update value on the entry object.

    Parameters

    • key: Key

      Name of the key.

    • value: Value

      Value associated with key.

    Returns CacheEntry<Key, Value>

    CacheEntry stored by backend.
    Upper level abstractions can attach properties to this object.

values

  • values(): IterableIterator<CacheEntry<Key, Value>>