KeyValueService abstracts the storage and retrieval of json-compatable values and provides management and expiration of those values. All methods are asynchronous.

const store: KeyValueService

Hierarchy

  • KeyValueService

Implemented by

Methods

  • checkHealth is for asserting that the store's connection is healthy, it should reject if it is not healthy.

    Returns Promise<void>

  • delete removes a value under a specific key.

    await store.delete('puppy_list')
    

    Parameters

    • key: string

    Returns Promise<void>

  • put adds a value to the store.

    await store.put('puppy_list', [{ name: 'Sandie' }])
    

    Type Parameters

    • T

    Parameters

    • key: string
    • value: T

    Returns Promise<void>

  • retrieve gets a value out of the store for you and allows you to cast it's type.

    interface Puppy {
    name: string
    }

    const value = await store.retrieve<Puppy[]>('puppy_list')

    Type Parameters

    • T

    Parameters

    • key: string

    Returns Promise<null | T>

  • setExpiry triggers the value under that key is removed in a certain amount of seconds.

    const oneMinute = 60
    await store.setExpiry('puppy_list', oneMinute)

    Parameters

    • key: string
    • duractionInSeconds: number

    Returns Promise<void>

Generated using TypeDoc