Constructors

  • Fetch cache for SublinksClient

    Parameters

    • ttl: number = 60

      Default cache duration, in seconds, for the cache. Default is 60 seconds

    • useCache: boolean = true

      Whether to use the cache by default if not specified. Default true

    Returns FetchCache

Properties

store: FetchCacheStore = ...
ttl: number
useCache: boolean

Methods

  • Get the age of a given key. Value is in seconds

    Parameters

    • key: string

      The cache key to lookup

    Returns number

  • Returns a cache key with a given name and optionally the parameters used for the call whose response should be cached

    Parameters

    • name: string

      The name of the calling function

    • data: any = {}

      An object of key/values that will be serialized to generate the key *

    Returns string

  • Deletes a key from the cache

    Parameters

    • key: string

      The key to delete. If ends with *, the key will be used as a prefix. e.g. del('the*') will delete keys the, thee, and there

    Returns void

  • Get a value for a given key. If not found, will return undefined. Data type should be specified by caller.

    Type Parameters

    • ReturnType

    Parameters

    • key: string

      The storage key to lookup

    • options: CacheOptions = {}

      Object representing the cache options. Can be passed directly from calling method

    Returns undefined | ReturnType

  • Delete any expired keys from the store. Uses the class-level TTL

    Parameters

    • maxAge: number = ...

      Delete any keys older than this value (in seconds) *

    Returns void

  • Returns the current date/time as a Unix timestamp rounded down to nearest second.

    Returns number

  • Stores a given key/value pair.

    Type Parameters

    • DataType

    Parameters

    • key: string

      Lookup key

    • value: DataType

      Any arbitrary data. Data type should be specified by caller

    • options: CacheOptions = {}

    Returns DataType

Generated using TypeDoc