Module: LaunchDarkly::Integrations::Util::FeatureStoreCore

Defined in:
lib/ldclient-rb/integrations/util/store_wrapper.rb

Overview

This module describes the methods that you must implement on your own object in order to use CachingStoreWrapper.

Since:

  • 5.5.0

Instance Method Summary collapse

Instance Method Details

#get_all_internal(kind) ⇒ Hash

Retrieves all entities of the specified kind. This is the same as LaunchDarkly::Interfaces::FeatureStore#all except that 1. the wrapper will take care of filtering out deleted entities by checking the ‘:deleted` property, so you can just return exactly what was in the data store, and 2. the wrapper will take care of checking and updating the cache if caching is enabled.

Parameters:

  • kind (Object)

    the kind of entity to get

Returns:

  • (Hash)

    a hash where each key is the entity’s ‘:key` property and each value is the entity

Since:

  • 5.5.0



205
206
# File 'lib/ldclient-rb/integrations/util/store_wrapper.rb', line 205

def get_all_internal(kind)
end

#get_internal(kind, key) ⇒ Hash

Retrieves a single entity. This is the same as LaunchDarkly::Interfaces::FeatureStore#get except that 1. the wrapper will take care of filtering out deleted entities by checking the ‘:deleted` property, so you can just return exactly what was in the data store, and 2. the wrapper will take care of checking and updating the cache if caching is enabled.

Parameters:

  • kind (Object)

    the kind of entity to get

  • key (String)

    the unique key of the entity to get

Returns:

  • (Hash)

    the entity; nil if the key was not found

Since:

  • 5.5.0



192
193
# File 'lib/ldclient-rb/integrations/util/store_wrapper.rb', line 192

def get_internal(kind, key)
end

#init_internal(all_data) ⇒ void

This method returns an undefined value.

Initializes the store. This is the same as LaunchDarkly::Interfaces::FeatureStore#init, but the wrapper will take care of updating the cache if caching is enabled.

If possible, the store should update the entire data set atomically. If that is not possible, it should iterate through the outer hash and then the inner hash using the existing iteration order of those hashes (the SDK will ensure that the items were inserted into the hashes in the correct order), storing each item, and then delete any leftover items at the very end.

Parameters:

  • all_data (Hash)

    a hash where each key is one of the data kind objects, and each value is in turn a hash of string keys to entities

Since:

  • 5.5.0



179
180
# File 'lib/ldclient-rb/integrations/util/store_wrapper.rb', line 179

def init_internal(all_data)
end

#initialized_internal?Boolean

Checks whether this store has been initialized. This is the same as LaunchDarkly::Interfaces::FeatureStore#initialized? except that there is less of a concern for efficiency, because the wrapper will use caching and memoization in order to call the method as little as possible.

Returns:

  • (Boolean)

    true if the store is in an initialized state

Since:

  • 5.5.0



233
234
# File 'lib/ldclient-rb/integrations/util/store_wrapper.rb', line 233

def initialized_internal?
end

#stopvoid

This method returns an undefined value.

Performs any necessary cleanup to shut down the store when the client is being shut down.

Since:

  • 5.5.0



241
242
# File 'lib/ldclient-rb/integrations/util/store_wrapper.rb', line 241

def stop
end

#upsert_internal(kind, item) ⇒ Hash

Attempts to add or update an entity. This is the same as LaunchDarkly::Interfaces::FeatureStore#upsert except that 1. the wrapper will take care of updating the cache if caching is enabled, and 2. the method is expected to return the final state of the entity (i.e. either the ‘item` parameter if the update succeeded, or the previously existing entity in the store if the update failed; this is used for the caching logic).

Note that FeatureStoreCore does not have a ‘delete` method. This is because CachingStoreWrapper implements `delete` by simply calling `upsert` with an item whose `:deleted` property is true.

Parameters:

  • kind (Object)

    the kind of entity to add or update

  • item (Hash)

    the entity to add or update

Returns:

  • (Hash)

    the entity as it now exists in the store after the update

Since:

  • 5.5.0



222
223
# File 'lib/ldclient-rb/integrations/util/store_wrapper.rb', line 222

def upsert_internal(kind, item)
end