Store defines a concurrent safe in memory key-value data store.

Type Parameters

  • T

Hierarchy

  • Store

Methods

  • Get returns a single element value from the store.

    If key is not set, the zero T value is returned.

    Parameters

    • key: string

    Returns T

  • Has checks if element with the specified key exist or not.

    Parameters

    • key: string

    Returns boolean

  • Length returns the current number of elements in the store.

    Returns number

  • Remove removes a single entry from the store.

    Remove does nothing if key doesn't exist in the store.

    Parameters

    • key: string

    Returns void

  • RemoveAll removes all the existing store entries.

    Returns void

  • Reset clears the store and replaces the store data with a shallow copy of the provided newData.

    Parameters

    Returns void

  • Set sets (or overwrite if already exist) a new value for key.

    Parameters

    • key: string
    • value: T

    Returns void

  • SetIfLessThanLimit sets (or overwrite if already exist) a new value for key.

    This method is similar to Set() but it will skip adding new elements to the store if the store length has reached the specified limit. false is returned if maxAllowedElements limit is reached.

    Parameters

    • key: string
    • value: T
    • maxAllowedElements: number

    Returns boolean

Generated using TypeDoc