Contains methods for configuring the SDK's persistent storage behavior.
public sealed class PersistenceConfigurationBuilder : Object
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).
var config = Configuration.Builder(sdkKey) .Persistence( Components.Persistence().MaxCachedUsers(5) ) .Build();
Default value for MaxCachedContexts(Int32): 5.
public const int DefaultMaxCachedContexts = 5
Passing this value (or any negative number) to MaxCachedContexts(Int32) means there is no limit on cached user data.
public const int UnlimitedCachedContexts = -1
Sets the maximum number of users to store flag data for.
public PersistenceConfigurationBuilder MaxCachedContexts(int maxCachedContexts)
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.
Sets the storage implementation.
public PersistenceConfigurationBuilder Storage(IComponentConfigurer<IPersistentDataStore> persistentDataStoreFactory)
a factory for the custom storage implementation, or null to use the default implementation
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.