Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Cache<Key, Value, ArgumentsBundle, Returns, EventValue>

Represents an abstraction over different cache implementations.

Type parameters

  • Key

    Type of the key.

  • Value

    Type of the value.

  • ArgumentsBundle

    Type of the arguments bundle passed to different operations.

  • Returns: "plain" | "promise"

    Type of the return value.

  • EventValue

    Type of the value emitted in the events payload.

Hierarchy

  • Cache

Implemented by

Properties

Methods

Properties

Readonly size

size: number

Number of cache entries.

Methods

clear

  • clear(): void
  • Clear all cache entries.
    After successful clear, CacheEvent.FLUSH event will be emitted.

    Returns void

del

  • del(key: Key): boolean
  • Delete key and it's associated value.
    After successful deletion, CacheEvent.DELETE event will be emitted.

    Parameters

    • key: Key

      Name of the key.

    Returns boolean

    Whether key was removed.

get

  • get(key: Key, argsBundle?: ArgumentsBundle): MaybePromise<undefined | Value, Returns>
  • Get the value associated with key.

    Parameters

    • key: Key

      Name of the key.

    • Optional argsBundle: ArgumentsBundle

      Bundle of arguments passed by client for this operation.

    Returns MaybePromise<undefined | Value, Returns>

has

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

    Parameters

    • key: Key

      Name of the key.

    Returns boolean

keys

  • keys(): Key[]
  • Get all cache keys.

    Returns Key[]

off

  • Unregister event listener.

    Parameters

    Returns Cache<Key, Value, ArgumentsBundle, Returns, EventValue>

on

  • Register event listener.

    Parameters

    Returns Cache<Key, Value, ArgumentsBundle, Returns, EventValue>

set

  • set(key: Key, value: Value, argsBundle?: ArgumentsBundle): void
  • Set value associated with key.
    After successful insertion/update, according CacheEvent.INSERT, respectively CacheEvent.UPDATE events will be emitted.

    Parameters

    • key: Key

      Name of the key.

    • value: Value

      It's associated value.

    • Optional argsBundle: ArgumentsBundle

      Bundle of arguments passed by client for this operation.

    Returns void