Show / Hide Table of Contents

Class PersistenceConfigurationBuilder

Contains methods for configuring the SDK's persistent storage behavior.

Inheritance
System.Object
PersistenceConfigurationBuilder
Namespace: LaunchDarkly.Sdk.Client.Integrations
Assembly: LaunchDarkly.ClientSdk.dll
Syntax
public sealed class PersistenceConfigurationBuilder : Object
Remarks

The persistent storage mechanism allows the SDK to immediately access the last known flag data for the user, if any, if it was started offline or has not yet received data from LaunchDarkly.

By default, the SDK uses a persistence mechanism that is specific to each platform, as described in Storage(IComponentConfigurer<IPersistentDataStore>). To use a custom persistence implementation, or to customize related properties defined in this class, create a builder with Persistence(), change its properties with the methods of this class, and pass it to Persistence(PersistenceConfigurationBuilder).

Examples
    var config = Configuration.Builder(sdkKey)
        .Persistence(
            Components.Persistence().MaxCachedUsers(5)
        )
        .Build();

Fields

DefaultMaxCachedContexts

Default value for MaxCachedContexts(Int32): 5.

Declaration
public const int DefaultMaxCachedContexts = 5
Field Value
Type Description
System.Int32

UnlimitedCachedContexts

Passing this value (or any negative number) to MaxCachedContexts(Int32) means there is no limit on cached user data.

Declaration
public const int UnlimitedCachedContexts = -1
Field Value
Type Description
System.Int32

Methods

MaxCachedContexts(Int32)

Sets the maximum number of users to store flag data for.

Declaration
public PersistenceConfigurationBuilder MaxCachedContexts(int maxCachedContexts)
Parameters
Type Name Description
System.Int32 maxCachedContexts
Returns
Type Description
PersistenceConfigurationBuilder
Remarks

A value greater than zero means that the SDK will use persistent storage to remember the last known flag values for up to that number of unique user keys. If the limit is exceeded, the SDK discards the data for the least recently used user.

A value of zero means that the SDK will not use persistent storage; it will only have whatever flag data it has received since the current LdClient instance was started.

A value of UnlimitedCachedContexts or any other negative number means there is no limit. Use this mode with caution, as it could cause the size of mobile device preferences to grow indefinitely if your application uses many different user keys on the same device.

Storage(IComponentConfigurer<IPersistentDataStore>)

Sets the storage implementation.

Declaration
public PersistenceConfigurationBuilder Storage(IComponentConfigurer<IPersistentDataStore> persistentDataStoreFactory)
Parameters
Type Name Description
IComponentConfigurer<IPersistentDataStore> persistentDataStoreFactory

a factory for the custom storage implementation, or null to use the default implementation

Returns
Type Description
PersistenceConfigurationBuilder

the builder

Remarks

By default, the SDK uses a persistence mechanism that is specific to each platform: on Android and iOS it is the native preferences store, and in the .NET Standard implementation for desktop apps it is the System.IO.IsolatedStorage API. You may use this method to specify a custom implementation using a factory object.

In This Article
Back to top Generated by DocFX