public final class RedisDataStoreBuilder extends java.lang.Object implements PersistentDataStoreFactory, DiagnosticDescription
Obtain an instance of this class by calling Redis.dataStore()
. After calling its methods
to specify any desired custom settings, you can pass it directly into the SDK configuration with
LDConfig.Builder.dataStore(com.launchdarkly.client.FeatureStoreFactory)
.
You do not need to call createPersistentDataStore()
yourself to build the actual data store; that
will be done by the SDK.
Builder calls can be chained, for example:
LDConfig config = new LDConfig.Builder()
.dataStore(
Components.persistentDataStore(
Redis.dataStore()
.url("redis://my-redis-host")
.database(1)
).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 |
---|---|
RedisDataStoreBuilder |
connectTimeout(int connectTimeout,
java.util.concurrent.TimeUnit timeUnit)
Optional override which sets the connection timeout for the underlying Jedis pool which otherwise defaults to
Protocol.DEFAULT_TIMEOUT |
FeatureStoreCore |
createPersistentDataStore()
Called internally from
PersistentDataStoreBuilder to create the implementation object
for the specific type of data store. |
RedisDataStoreBuilder |
database(java.lang.Integer database)
Specifies the database number to use.
|
LDValue |
describeConfiguration(LDConfig config)
Used internally by the SDK to inspect the configuration.
|
RedisDataStoreBuilder |
password(java.lang.String password)
Specifies a password that will be sent to Redis in an AUTH command.
|
RedisDataStoreBuilder |
poolConfig(redis.clients.jedis.JedisPoolConfig poolConfig)
Optional override if you wish to specify your own configuration to the underlying Jedis pool.
|
RedisDataStoreBuilder |
prefix(java.lang.String prefix)
Optionally configures the namespace prefix for all keys stored in Redis.
|
RedisDataStoreBuilder |
socketTimeout(int socketTimeout,
java.util.concurrent.TimeUnit timeUnit)
Optional override which sets the connection timeout for the underlying Jedis pool which otherwise defaults to
Protocol.DEFAULT_TIMEOUT |
RedisDataStoreBuilder |
tls(boolean tls)
Optionally enables TLS for secure connections to Redis.
|
RedisDataStoreBuilder |
uri(java.net.URI redisUri)
Specifies a Redis host URI other than
DEFAULT_URI . |
public static final java.net.URI DEFAULT_URI
redis://localhost:6379
public static final java.lang.String DEFAULT_PREFIX
prefix(String)
.public RedisDataStoreBuilder 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 RedisDataStoreBuilder 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 RedisDataStoreBuilder 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 RedisDataStoreBuilder uri(java.net.URI redisUri)
DEFAULT_URI
.redisUri
- the URI of the Redis hostpublic RedisDataStoreBuilder prefix(java.lang.String prefix)
prefix
- the namespace prefixpublic RedisDataStoreBuilder poolConfig(redis.clients.jedis.JedisPoolConfig poolConfig)
poolConfig
- the Jedis pool configuration.public RedisDataStoreBuilder connectTimeout(int connectTimeout, java.util.concurrent.TimeUnit timeUnit)
Protocol.DEFAULT_TIMEOUT
connectTimeout
- the timeouttimeUnit
- the time unit for the timeoutpublic RedisDataStoreBuilder socketTimeout(int socketTimeout, java.util.concurrent.TimeUnit timeUnit)
Protocol.DEFAULT_TIMEOUT
socketTimeout
- the socket timeouttimeUnit
- the time unit for the timeoutpublic FeatureStoreCore createPersistentDataStore()
PersistentDataStoreFactory
PersistentDataStoreBuilder
to create the implementation object
for the specific type of data store.createPersistentDataStore
in interface PersistentDataStoreFactory
public LDValue describeConfiguration(LDConfig config)
DiagnosticDescription
describeConfiguration
in interface DiagnosticDescription
config
- the full configuration, in case this component depends on properties outside itselfLDValue
or null