Interface IPersistentDataStore
Interface for a data store that holds feature flag data and other SDK properties in a serialized form.
Inherited Members
Namespace: LaunchDarkly.Sdk.Client.Subsystems
Assembly: LaunchDarkly.ClientSdk.dll
Syntax
public interface IPersistentDataStore : IDisposable
Remarks
This interface should be used for platform-specific integrations that store data somewhere
other than in memory. The SDK has a default implementation which uses the native preferences
API on mobile platforms, and the .NET IsolatedStorage
API in desktop applications. You
only need to use this interface if you want to provide different storage behavior.
Each data item is uniquely identified by the combination of a "namespace" and a "key", and has a string value. These are defined as follows:
- Both the namespace and the key are non-null and non-empty strings.
- Both the namespace and the key contain only alphanumeric characters, hyphens, and underscores.
- The namespace always starts with "LaunchDarkly".
- The value can be any non-null string, including an empty string.
Unlike server-side SDKs, the persistent data store in this SDK treats the entire set of flags for a given user as a single value which is written to the store all at once, rather than one value per flag. This is for two reasons:
- The SDK assumes that the persistent store cannot be written to by any other process, so it does not need to implement read-through behavior when getting individual flags, and can read flags only from the in-memory cache. It only needs to read the persistent store at startup time or when changing users, to get any last known data for all flags at once.
- On many platforms, reading or writing multiple separate keys may be inefficient or may not be possible to do atomically.
The SDK will also provide its own caching layer on top of the persistent data store; the data store implementation should not provide caching, but simply do every query or update that the SDK tells it to do.
Implementations do not need to worry about thread-safety; the SDK will ensure that it only calls one store method at a time.
Error handling is defined as follows: if any data store operation encounters an I/O error, or is otherwise unable to complete its task, it should throw an exception to make the SDK aware of this. The SDK will decide whether to log the exception.
Methods
| Edit this page View SourceGetValue(string, string)
Attempts to retrieve a string value from the store.
Declaration
string GetValue(string storageNamespace, string key)
Parameters
Type | Name | Description |
---|---|---|
string | storageNamespace | the namespace identifier |
string | key | the unique key within that namespace |
Returns
Type | Description |
---|---|
string | the value, or null if not found |
SetValue(string, string, string)
Attempts to update or remove a string value in the store.
Declaration
void SetValue(string storageNamespace, string key, string value)
Parameters
Type | Name | Description |
---|---|---|
string | storageNamespace | the namespace identifier |
string | key | the unique key within that namespace |
string | value | the new value, or null to remove the key |