T - the component type that this builder is being used forpublic abstract class RedisStoreBuilder<T>
extends java.lang.Object
implements com.launchdarkly.sdk.server.subsystems.ComponentConfigurer<T>, com.launchdarkly.sdk.server.subsystems.DiagnosticDescription
Both Redis.dataStore() and Redis.bigSegmentStore() return instances of
this class. You can use methods of the builder to specify any non-default Redis options
you may want, before passing the builder to either Components.persistentDataStore(ComponentConfigurer)
or Components.bigSegments(ComponentConfigurer) as appropriate. The two types of
stores are independent of each other; you do not need a Big Segment store if you are not
using the Big Segments feature, and you do not need to use the same database for both.
In this example, the main data store uses a Redis host called "host1", and the Big Segment
store uses a Redis host called "host2":
LDConfig config = new LDConfig.Builder()
.dataStore(
Components.persistentDataStore(
Redis.dataStore().uri(URI.create("redis://host1:6379")
)
)
.bigSegments(
Components.bigSegments(
Redis.dataStore().uri(URI.create("redis://host2:6379")
)
)
.build();
Note that the SDK also has its own options related to data storage that are configured
at a different level, because they are independent of what database is being used. For
instance, the builder returned by Components.persistentDataStore(ComponentConfigurer)
has options for caching:
LDConfig config = new LDConfig.Builder()
.dataStore(
Components.persistentDataStore(
Redis.dataStore().uri(URI.create("redis://my-redis-host"))
).cacheSeconds(15)
)
.build();
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_PREFIX
The default value for
prefix(String). |
static java.net.URI |
DEFAULT_URI
The default value for the Redis URI:
redis://localhost:6379 |
| Modifier and Type | Method and Description |
|---|---|
RedisStoreBuilder<T> |
connectTimeout(java.time.Duration connectTimeout)
Optional override which sets the connection timeout for the underlying Jedis pool which otherwise defaults to
Protocol.DEFAULT_TIMEOUT milliseconds. |
RedisStoreBuilder<T> |
database(java.lang.Integer database)
Specifies the database number to use.
|
com.launchdarkly.sdk.LDValue |
describeConfiguration(com.launchdarkly.sdk.server.subsystems.ClientContext clientContext) |
RedisStoreBuilder<T> |
password(java.lang.String password)
Specifies a password that will be sent to Redis in an AUTH command.
|
RedisStoreBuilder<T> |
poolConfig(redis.clients.jedis.JedisPoolConfig poolConfig)
Optional override if you wish to specify your own configuration to the underlying Jedis pool.
|
RedisStoreBuilder<T> |
prefix(java.lang.String prefix)
Optionally configures the namespace prefix for all keys stored in Redis.
|
RedisStoreBuilder<T> |
socketTimeout(java.time.Duration socketTimeout)
Optional override which sets the connection timeout for the underlying Jedis pool which otherwise defaults to
Protocol.DEFAULT_TIMEOUT milliseconds. |
RedisStoreBuilder<T> |
tls(boolean tls)
Optionally enables TLS for secure connections to Redis.
|
RedisStoreBuilder<T> |
uri(java.net.URI redisUri)
Specifies a Redis host URI other than
DEFAULT_URI. |
public static final java.net.URI DEFAULT_URI
redis://localhost:6379public static final java.lang.String DEFAULT_PREFIX
prefix(String).public RedisStoreBuilder<T> database(java.lang.Integer database)
The database number can also be specified in the Redis URI, in the form redis://host:port/NUMBER. Any
non-null value that you set with database(Integer) will override the URI.
database - the database number, or null to fall back to the URI or the defaultpublic RedisStoreBuilder<T> password(java.lang.String password)
It is also possible to include a password in the Redis URI, in the form redis://:PASSWORD@host:port. Any
password that you set with password(String) will override the URI.
password - the passwordpublic RedisStoreBuilder<T> tls(boolean tls)
This is equivalent to specifying a Redis URI that begins with rediss: rather than redis:.
Note that not all Redis server distributions support TLS.
tls - true to enable TLSpublic RedisStoreBuilder<T> uri(java.net.URI redisUri)
DEFAULT_URI.redisUri - the URI of the Redis hostpublic RedisStoreBuilder<T> prefix(java.lang.String prefix)
prefix - the namespace prefixpublic RedisStoreBuilder<T> poolConfig(redis.clients.jedis.JedisPoolConfig poolConfig)
poolConfig - the Jedis pool configuration.public RedisStoreBuilder<T> connectTimeout(java.time.Duration connectTimeout)
Protocol.DEFAULT_TIMEOUT milliseconds.connectTimeout - the timeoutpublic RedisStoreBuilder<T> socketTimeout(java.time.Duration socketTimeout)
Protocol.DEFAULT_TIMEOUT milliseconds.socketTimeout - the socket timeoutpublic com.launchdarkly.sdk.LDValue describeConfiguration(com.launchdarkly.sdk.server.subsystems.ClientContext clientContext)
describeConfiguration in interface com.launchdarkly.sdk.server.subsystems.DiagnosticDescription