C++ Client-Side SDK
LaunchDarkly SDK
Public Member Functions | List of all members
IPersistence Class Referenceabstract

#include <persistence.hpp>

Inheritance diagram for IPersistence:
Inheritance graph
[legend]

Public Member Functions

virtual void Set (std::string storage_namespace, std::string key, std::string data) noexcept=0
 
virtual void Remove (std::string storage_namespace, std::string key) noexcept=0
 
virtual std::optional< std::string > Read (std::string storage_namespace, std::string key) noexcept=0
 

Detailed Description

Interface for a data store that holds feature flag data and other SDK properties in a serialized form.

This interface should be used for platform-specific integrations that store data somewhere other than in memory. The SDK defaults to using only in-memory storage. 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:

The SDK assumes that the persistence is only being used by a single instance of the SDK per SDK key (two different SDK instances, with 2 different SDK keys could use the same persistence instance). It does not implement read-through behavior. It reads values at SDK initialization or when changing contexts.

The SDK, with correct usage, will not have overlapping writes to the same key. The Read/Write methods may not always be called from the same thread.

This interface does not depend on the ability to list the contents of the store or namespaces. This is to maintain the simplicity of implementing a key-value store on many platforms.

Member Function Documentation

◆ Read()

virtual std::optional<std::string> IPersistence::Read ( std::string  storage_namespace,
std::string  key 
)
pure virtualnoexcept

Attempt to read a value from the store.

Parameters
storage_namespaceThe namespace of the data.
keyThe key of the data.
Returns
The read value, or std::nullopt if the value does not exist or could not be read.

Implemented in PersistenceImplementationWrapper.

◆ Remove()

virtual void IPersistence::Remove ( std::string  storage_namespace,
std::string  key 
)
pure virtualnoexcept

Remove a value from the store. If the value cannot be removed, then the function should complete normally.

Parameters
storage_namespaceThe namespace of the data.
keyThe key of the data.

Implemented in PersistenceImplementationWrapper.

◆ Set()

virtual void IPersistence::Set ( std::string  storage_namespace,
std::string  key,
std::string  data 
)
pure virtualnoexcept

Add or update a value in the store. If the value cannot be set, then the function should complete normally.

Parameters
storage_namespaceThe namespace for the data.
keyThe key for the data.
dataThe data to add or update.

Implemented in PersistenceImplementationWrapper.


The documentation for this class was generated from the following file: