Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface for a feature store component.

The feature store is what the client uses to store feature flag data that has been received from LaunchDarkly. By default, it uses an in-memory implementation; there are also adapters for Redis and other databases (see the SDK Reference Guide). You will not need to use this interface unless you are writing your own implementation.

Feature store methods can and should call their callbacks directly whenever possible, rather than deferring them with setImmediate() or process.nextTick(). This means that if for any reason you are updating or querying a feature store directly in your application code (which is not part of normal use of the SDK) you should be aware that the callback may be executed immediately.

Hierarchy

  • LDFeatureStore

Index

Methods

all

  • all(kind: object, callback: function): void
  • Get all entities from a collection.

    The store should filter out any entities with the property deleted: true.

    Parameters

    • kind: object

      The type of data to be accessed. The namespace property of this object indicates which collection of entities to use, e.g. "features" or "segments". The store should not make any assumptions about the format of the data, but just return an object in which each key is the key property of an entity and the value is the entity.

    • callback: function

      Will be called with the resulting map.

        • (res: object): void
        • Parameters

          • res: object

          Returns void

    Returns void

close

  • close(): void
  • Releases any resources being used by the feature store.

    Returns void

delete

  • delete(kind: object, key: string, version: string, callback: function): void
  • Delete an entity from the store.

    Deletion should be implemented by storing a placeholder object with the property deleted: true and a version property equal to the provided version. In other words, it should be exactly the same as calling upsert with such an object.

    Parameters

    • kind: object

      The type of data to be accessed. The namespace property of this object indicates which collection of entities to use, e.g. "features" or "segments".

    • key: string

      The unique key of the entity within the specified collection.

    • version: string

      A number that must be greater than the version property of the existing entity in order for it to be deleted. If it is less than or equal to the existing version, the method should do nothing.

    • callback: function

      Will be called when the delete operation is complete.

        • (): void
        • Returns void

    Returns void

get

  • get(kind: object, key: string, callback: function): void
  • Get an entity from the store.

    The store should treat any entity with the property deleted: true as "not found".

    Parameters

    • kind: object

      The type of data to be accessed. The namespace property of this object indicates which collection of entities to use, e.g. "features" or "segments". The store should not make any assumptions about the format of the data, but just return a JSON object.

    • key: string

      The unique key of the entity within the specified collection.

    • callback: function

      Will be called with the retrieved entity, or null if not found.

        • (res: object): void
        • Parameters

          • res: object

          Returns void

    Returns void

init

  • init(allData: object, callback: function): void
  • Initialize the store, overwriting any existing data.

    Parameters

    • allData: object

      An object in which each key is the "namespace" of a collection (e.g. "features") and the value is an object that maps keys to entities.

    • callback: function

      Will be called when the store has been initialized.

        • (): void
        • Returns void

    Returns void

initialized

  • initialized(callback: function): void
  • Tests whether the store is initialized.

    "Initialized" means that the store has been populated with data, either by the client having called init() within this process, or by another process (if this is a shared database).

    Parameters

    • callback: function

      Will be called back with the boolean result.

        • (isInitialized: boolean): void
        • Parameters

          • isInitialized: boolean

          Returns void

    Returns void

upsert

  • upsert(kind: object, data: object, callback: function): void
  • Add an entity or update an existing entity.

    Parameters

    • kind: object

      The type of data to be accessed. The namespace property of this object indicates which collection of entities to use, e.g. "features" or "segments". The store should not make any assumptions about the format of the data, but just return a JSON object.

    • data: object

      The contents of the entity, as an object that can be converted to JSON. The store should check the version property of this object, and should not overwrite any existing data if the existing version is greater than or equal to that value.

    • callback: function

      Will be called after the upsert operation is complete.

        • (): void
        • Returns void

    Returns void

Generated using TypeDoc