Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Cache

Index

Constructors

Properties

Methods

Constructors

constructor

  • Instantiate a new Cache with given driver. The driver is optional; if unspecified, defaults to Memory driver.

    Parameters

    Returns Cache

Properties

Protected driver

driver: Driver

Methods

close

  • close(): Promise<boolean>
  • Closes underlying driver. If external cache drivers (e.g. Redis) are used, this will close the connection. Use this method to clean up and teardown.

    Returns Promise<boolean>

delete

  • delete(keys: string | string[]): Promise<number>
  • Delete one or more keys.

    Parameters

    • keys: string | string[]

      key name

    Returns Promise<number>

expire

  • expire(key: string, ttl: number): Promise<boolean>
  • Update key with new expiry time in seconds.

    Parameters

    • key: string

      key name

    • ttl: number

      key lifetime in seconds

    Returns Promise<boolean>

get

  • get(key: string): Promise<any>
  • Get cached value at given key.

    Parameters

    • key: string

      key name

    Returns Promise<any>

has

  • has(key: string): Promise<boolean>
  • Get whether the key exists in cache.

    Parameters

    • key: string

      key name

    Returns Promise<boolean>

keys

  • keys(): Promise<string[]>
  • Retrieve all keys.

    Returns Promise<string[]>

set

  • set(key: string, value: any, ttl?: number): Promise<boolean>
  • Set value to cache at given key.

    Parameters

    • key: string

      key name

    • value: any

      value to cache

    • Optional ttl: number

    Returns Promise<boolean>

ttl

  • ttl(key: string): Promise<number>
  • Get remaining expiry time in seconds.

    Parameters

    • key: string

      key name

    Returns Promise<number>

Generated using TypeDoc