LaunchDarkly Server-side SDK for Rust - Redis integration with redis client

Circle CI

This library provides a Redis-backed persistence mechanism (data store) for the LaunchDarkly Rust SDK, replacing the default in-memory data store.

The Redis API implementation it uses is redis. There are other Redis client implementations for Rust; if LaunchDarkly SDK Redis integrations using other Redis clients are released, they will be in separate repositories.

For more information, see also: Using a persistent feature store.

LaunchDarkly overview

LaunchDarkly is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. Get started using LaunchDarkly today!

Twitter Follow

Quick setup

This assumes that you have already installed the LaunchDarkly Rust SDK.

  1. Import the LaunchDarkly SDK packages and the package for this library:

rust use launchdarkly_server_sdk::{Client, ConfigBuilder, PersistentDataStoreBuilder}; use launchdarkly_server_sdk_redis::RedisPersistentDataStoreFactory; use std::sync::Arc;

  1. When configuring your SDK client, provide the ConfigBuilder with an instance of the PersistentDataStoreBuilder. You may specify any custom Redis options using the methods of RedisPersistentDataStoreFactory. For instance, to customize the Redis URL:

```rust let mut redisfactory = RedisPersistentDataStoreFactory::new(); redisfactory.url("redis://localhost:9000"); let persistentdatastorebuilder = PersistentDataStoreBuilder::new(Arc::new(redisfactory));

let mut configbuilder = ConfigBuilder::new(&sdkkey); configbuilder = configbuilder.datastore(&persistentdatastorebuilder); ```

By default, the store will try to connect to a local Redis instance on port 6379.

Caching behavior

The LaunchDarkly SDK has a standard caching mechanism for any persistent data store, to reduce database traffic. This is configured through the SDK's PersistentDataStoreBuilder class as described in the SDK documentation. For instance, to specify a cache TTL of 5 minutes:

rust let mut persistent_data_store_builder = PersistentDataStoreBuilder::new(Arc::new(redis_factory)); persistent_data_store_builder.cache_time(std::time::Duration::from_secs(5 * 60));

About LaunchDarkly