# LaunchDarkly Server-side SDK for Rust - Redis integration with redis client [![Circle CI](https://circleci.com/gh/launchdarkly/rust-server-sdk-redis.svg?style=shield)](https://circleci.com/gh/launchdarkly/rust-server-sdk-redis) This library provides a [Redis](https://redis.io/)-backed persistence mechanism (data store) for the [LaunchDarkly Rust SDK](https://github.com/launchdarkly/rust-server-sdk), replacing the default in-memory data store. The Redis API implementation it uses is [redis](https://crates.io/crates/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](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store). ## LaunchDarkly overview [LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/docs/getting-started) using LaunchDarkly today! [![Twitter Follow](https://img.shields.io/twitter/follow/launchdarkly.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/intent/follow?screen_name=launchdarkly) ## 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; ``` 2. 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 redis_factory = RedisPersistentDataStoreFactory::new(); redis_factory.url("redis://localhost:9000"); 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); ``` 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 * 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 a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com/docs) for a complete list. * Explore LaunchDarkly * [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information * [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides * [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation * [launchdarkly.com/blog](https://launchdarkly.com/blog/ "LaunchDarkly Blog Documentation") for the latest product updates