Class AirshipCacheStoreService

The Cache Store provides simple key/value cache storage.

The Cache Store provides non-durable storage that can be accessed from any game server. Data access is faster than the Data Store, but the data will expire if it is not accessed frequently enough. Cached keys can live for up to 24 hours without being accessed.

The Cache Store is good for things like queue cooldowns or share codes. If you want your data to be persistent, check out the Data Store.

Methods

  • Checks that the key is valid. Throws an error if not valid.

    Parameters

    • key: string

    Returns void

  • Deletes the data associated with the provided key.

    Parameters

    • key: string

      The key to use. Keys must be alphanumeric and may include the following symbols: _.:

    Returns Promise<Result<number, undefined>>

  • Gets the cached data for the provided key.

    Type Parameters

    • T extends object

    Parameters

    • key: string

      Key to use. Keys must be alphanumeric and may include the following symbols: _.:

    • Optional expireTimeSec: number

      The duration this key should live after being accessed in seconds. If not provided, key duration will be unchanged. The maximum expire time is 24 hours.

    Returns Promise<Result<undefined | T, undefined>>

    The data associated with the provided key. If no data is associated with the provided key, then nothing will be returned.

  • Sets the data for the given key.

    Type Parameters

    • T extends object

    Parameters

    • key: string

      The key to use. Keys must be alphanumeric and may include the following symbols: _.:

    • data: T

      The data to associate with the provided key.

    • expireTimeSec: number

      The duration this key should live after being set in seconds. The maximum duration is 24 hours.

    Returns Promise<Result<T, undefined>>

    The data that was associated with the provided key.

  • Sets a new lifetime for the given key.

    Parameters

    • key: string

      The key to use. Keys must be alphanumeric and may include the following symbols: _.:

    • expireTimeSec: number

      The duration this key should live in seconds. The maximum duration is 24 hours.

    Returns Promise<Result<number, undefined>>

    The new lifetime of the key.