Expand description

launchdarkly-server-sdk-redis provides a Redis-backed persistent data store for the LaunchDarkly Redis SDK.

For more details about how and why you can use a persistent data store, see: https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store

To use the Redis data store with the LaunchDarkly client:

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

let redis_factory = RedisPersistentDataStoreFactory::new();
let persistent_data_store_builder = PersistentDataStoreBuilder::new(Arc::new(redis_factory));

let mut config_builder = ConfigBuilder::new(&sdk_key);
config_builder = config_builder.data_store(&persistent_data_store_builder);

The default Redis configuration uses an address of localhost:6379. You may customize the configuration by using the methods of the RedisPersistentDataStoreFactory.

let mut redis_factory = RedisPersistentDataStoreFactory::new();
redis_factory.url("redis://localhost:9999").prefix("new-prefix");

The SDK provides a caching mechanism on top of the persistent data stores. You can configure this cache lifetime by calling methods on the launchdarkly_server_sdk::PersistentDataStoreBuilder struct.

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));

Note that some Redis client features can also be specified as part of the URL: redis supports the redis:// syntax (https://www.iana.org/assignments/uri-schemes/prov/redis), which can include a password and a database number, as well as rediss:// (https://www.iana.org/assignments/uri-schemes/prov/rediss), which enables TLS.

If you are also using Redis for other purposes, the data store can coexist with other data as long as you are not using the same keys. By default, the keys used by the data store will always start with “launchdarkly:”; you can change this to another prefix if desired.

Structs

Contains methods for configuring a RedisPersistentDataStore.