1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! 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:
//!
//! ```rust
//! 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 sdk_key = "example-sdk-key";
//! 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].
//!
//!
//! ```rust
//! # use launchdarkly_server_sdk_redis::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.
//!
//! ```rust
//! # use launchdarkly_server_sdk::PersistentDataStoreBuilder;
//! # use launchdarkly_server_sdk_redis::RedisPersistentDataStoreFactory;
//! # let redis_factory = RedisPersistentDataStoreFactory::new();
//! # use std::sync::Arc;
//! 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.
pub use RedisPersistentDataStoreFactory;