LaunchDarkly SDK for .NET - Redis integration
This library provides a Redis-backed persistence mechanism (feature store) for the LaunchDarkly .NET SDK, replacing the default in-memory feature store. The underlying Redis client implementation is StackExchange.Redis.
The minimum version of the LaunchDarkly .NET SDK for use with this library is 5.6.1.
For more information, see also: Using a persistent feature store.
.NET platform compatibility
This version of the library is compatible with .NET Framework version 4.5 and above, .NET Standard 1.6, and .NET Standard 2.0.
Use NuGet to add this package to your project:
Or, if you require a strong-named assembly (note that this will result in a transitive dependency on StackExchange.Redis.StrongName, rather than StackExchange.Redis):
Import the package:
When configuring your
LDClient, add the Redis feature store:
Configuration ldConfig = Configuration.Default("YOUR_SDK_KEY") .WithFeatureStoreFactory(RedisComponents.RedisFeatureStore()); LdClient ldClient = new LdClient(ldConfig);
Optionally, you can change the Redis configuration by calling methods on the builder returned by
Configuration ldConfig = Configuration.Default("YOUR_SDK_KEY") .WithFeatureStoreFactory( RedisComponents.RedisFeatureStore() .WithRedisHostAndPort("my-redis-host", 6379) .WithConnectTimeout(TimeSpan.FromSeconds(3)) ); LdClient ldClient = new LdClient(ldConfig);
If you are running a LaunchDarkly Relay Proxy instance, you can use it in daemon mode, so that the SDK retrieves flag data only from Redis and does not communicate directly with LaunchDarkly. This is controlled by the SDK's
Configuration ldConfig = Configuration.Default("YOUR_SDK_KEY") .WithFeatureStoreFactory(RedisComponents.RedisFeatureStore()) .WithUseLdd(true); LdClient ldClient = new LdClient(ldConfig);
To reduce traffic to the Redis server, there is an optional in-memory cache that retains the last known data for a configurable amount of time. This is on by default; to turn it off (and guarantee that the latest feature flag data will always be retrieved from Redis for every flag evaluation), configure the builder as follows:
Or, to cache for longer than the default of 30 seconds:
The published versions of these assemblies are digitally signed by LaunchDarkly.
LaunchDarkly.Client.Redis.StrongName assembly is also strong-named;
LaunchDarkly.Client.Redis is not strong-named. The reason for this difference is that the StackExchange.Redis library is also built in two versions so if LaunchDarkly provided only a strong-named version, it would cause a dependency conflict if the application happened to be using the non-strong-named version of StackExchange.Redis for other purposes.
Building the code locally in the default Debug configuration does not sign the assembly and does not require a key file.
This project imports the
dotnet-client-shared-tests repositories as subtrees. See the
README.md file in each of those directories for more information.
To run unit tests, you must have a local Redis server.
Releases are done using the release script in
dotnet-base. Since the published package includes a .NET Framework 4.5 build, the release must be done from Windows.
- LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
- Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
- Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
- Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
- Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
- LaunchDarkly provides feature flag SDKs for
- Explore LaunchDarkly