Interface IDataStore
Interface for a data store that holds feature flags and related data received by the SDK.
Inherited Members
Namespace: LaunchDarkly.Sdk.Server.Subsystems
Assembly: LaunchDarkly.ServerSdk.dll
Syntax
public interface IDataStore : IDisposable
Remarks
Ordinarily, the only implementation of this interface is the default in-memory implementation, which holds references to actual SDK data model objects. Any data store implementation that uses an external store, such as a database, should instead use IPersistentDataStore or IPersistentDataStoreAsync.
Implementations must be thread-safe.
Properties
| Edit this page View SourceStatusMonitoringEnabled
True if this data store implementation supports status monitoring.
Declaration
bool StatusMonitoringEnabled { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
This is normally only true for persistent data stores created with PersistentDataStore(IComponentConfigurer<IPersistentDataStore>), but it could also be true for any custom IDataStore implementation that makes use of the IDataStoreUpdates mechanism. Returning true means that the store guarantees that if it ever enters an invalid state (that is, an operation has failed or it knows that operations cannot succeed at the moment), it will publish a status update, and will then publish another status update once it has returned to a valid state.
The same value will be returned from StatusMonitoringEnabled.
Methods
| Edit this page View SourceGet(DataKind, string)
Retrieves an item from the specified collection, if available.
Declaration
DataStoreTypes.ItemDescriptor? Get(DataStoreTypes.DataKind kind, string key)
Parameters
Type | Name | Description |
---|---|---|
DataStoreTypes.DataKind | kind | specifies which collection to use |
string | key | the unique key of the item within that collection |
Returns
Type | Description |
---|---|
DataStoreTypes.ItemDescriptor? | a versioned item that contains the stored data (or placeholder for deleted data); null if the key is unknown |
Remarks
If the item has been deleted and the store contains a placeholder, it should return that placeholder rather than null.
GetAll(DataKind)
Retrieves all items from the specified collection.
Declaration
DataStoreTypes.KeyedItems<DataStoreTypes.ItemDescriptor> GetAll(DataStoreTypes.DataKind kind)
Parameters
Type | Name | Description |
---|---|---|
DataStoreTypes.DataKind | kind | specifies which collection to use |
Returns
Type | Description |
---|---|
DataStoreTypes.KeyedItems<DataStoreTypes.ItemDescriptor> | a collection of key-value pairs; the ordering is not significant |
Remarks
If the store contains placeholders for deleted items, it should include them in the results, not filter them out.
Init(FullDataSet<ItemDescriptor>)
Overwrites the store's contents with a set of items for each collection.
Declaration
void Init(DataStoreTypes.FullDataSet<DataStoreTypes.ItemDescriptor> allData)
Parameters
Type | Name | Description |
---|---|---|
DataStoreTypes.FullDataSet<DataStoreTypes.ItemDescriptor> | allData | a list of DataStoreTypes.DataKind instances and their corresponding data sets |
Remarks
All previous data should be discarded, regardless of versioning.
The update should be done atomically. If it cannot be done atomically, then the store must first add or update each item in the same order that they are given in the input data, and then delete any previously stored items that were not in the input data.
Initialized()
Checks whether this store has been initialized with any data yet.
Declaration
bool Initialized()
Returns
Type | Description |
---|---|
bool | true if the store contains data |
Remarks
This is defined as a method rather than a property to emphasize that it may be an operation that involves I/O; some data stores need to do a database query to see if there is existing data.
Upsert(DataKind, string, ItemDescriptor)
Updates or inserts an item in the specified collection. For updates, the object will only be updated if the existing version is less than the new version.
Declaration
bool Upsert(DataStoreTypes.DataKind kind, string key, DataStoreTypes.ItemDescriptor item)
Parameters
Type | Name | Description |
---|---|---|
DataStoreTypes.DataKind | kind | specifies which collection to use |
string | key | the unique key for the item within that collection |
DataStoreTypes.ItemDescriptor | item | the item to insert or update |
Returns
Type | Description |
---|---|
bool | true if the item was updated; false if it was not updated because the store contains an equal or greater version |
Remarks
The SDK may pass an DataStoreTypes.ItemDescriptor that contains a null, to represent a placeholder for a deleted item. In that case, assuming the version is greater than any existing version of that item, the store should retain that placeholder rather than simply not storing anything.