@launchdarkly/js-server-sdk-common - v2.26.1
    Preparing search index...

    Class TransactionalFeatureStore

    Wraps a non-transactional LDFeatureStore and makes it transactional through an in-memory store acting as a cache.

    It also monitors the mirrored writes to the persistence store. A failed write marks the store unavailable. When the store recovers, this writes the full in-memory data set back to it.

    At most one full-store write is in flight at a time: a new write-back starts only after the previous write-back's store call has answered. A write-back is never abandoned. Its answer, however late, decides the outcome.

    Implements

    Index
    • Applies the provided data onto the existing data, replacing all data or upserting depending on the basis parameter. Must call applyChanges providing basis before calling applyChanges that is not a basis.

      Parameters

      • basis: boolean

        If true, completely overwrites the current contents of the data store with the provided data. If false, upserts the items in the provided data. Upserts are made only if provided items have newer versions than existing items.

      • data: LDFeatureStoreDataStorage

        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. The actual type of this parameter is interfaces.FullDataSet<VersionedData>.

      • callback: () => void

        Will be called after the changes are applied.

      • OptionalinitMetadata: InitMetadata

        Optional metadata to initialize the feature store with.

      • Optionalselector: string

        opaque string that uniquely identifies the state that contains the changes

      Returns 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: DataKind

        The type of data to be accessed. The actual type of this parameter is interfaces.DataKind.

      • key: string

        The unique key of the entity within the specified collection.

      • version: number

        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: () => void

        Will be called when the delete operation is complete.

      Returns 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: (isInitialized: boolean) => void

        Will be called back with the boolean result.

      Returns void