public final class RedisFeatureStoreBuilder extends java.lang.Object implements FeatureStoreFactory
RedisFeatureStore
.
A builder that helps construct RedisFeatureStore
objects.
RedisFeatureStoreBuilder
calls can be chained, enabling the following pattern:
RedisFeatureStore store = new RedisFeatureStoreBuilder("host", 443, 60) .refreshStaleValues(true) .asyncRefresh(true) .socketTimeout(200) .build()
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_CACHE_TIME_SECONDS
Deprecated.
|
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 |
Constructor and Description |
---|
RedisFeatureStoreBuilder(java.lang.String scheme,
java.lang.String host,
int port,
long cacheTimeSecs)
Deprecated.
Please use
Components.redisFeatureStore(java.net.URI) . |
RedisFeatureStoreBuilder(java.net.URI uri,
long cacheTimeSecs)
Deprecated.
Please use
Components.redisFeatureStore(java.net.URI) . |
Modifier and Type | Method and Description |
---|---|
RedisFeatureStoreBuilder |
asyncRefresh(boolean enabled)
|
RedisFeatureStore |
build()
Build a
RedisFeatureStore based on the currently configured builder object. |
RedisFeatureStoreBuilder |
cacheTime(long cacheTime,
java.util.concurrent.TimeUnit timeUnit)
Deprecated.
|
RedisFeatureStoreBuilder |
caching(FeatureStoreCacheConfig caching)
Specifies whether local caching should be enabled and if so, sets the cache properties.
|
RedisFeatureStoreBuilder |
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 |
RedisFeatureStore |
createFeatureStore()
Synonym for
build() . |
RedisFeatureStoreBuilder |
poolConfig(redis.clients.jedis.JedisPoolConfig poolConfig)
Optional override if you wish to specify your own configuration to the underlying Jedis pool.
|
RedisFeatureStoreBuilder |
prefix(java.lang.String prefix)
Optionally configures the namespace prefix for all keys stored in Redis.
|
RedisFeatureStoreBuilder |
refreshStaleValues(boolean enabled)
|
RedisFeatureStoreBuilder |
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 |
public static final java.net.URI DEFAULT_URI
redis://localhost:6379
public static final java.lang.String DEFAULT_PREFIX
prefix(String)
.public static final long DEFAULT_CACHE_TIME_SECONDS
FeatureStoreCacheConfig.DEFAULT
.cacheTime(long, TimeUnit)
(in seconds).public RedisFeatureStoreBuilder(java.net.URI uri, long cacheTimeSecs)
Components.redisFeatureStore(java.net.URI)
.RedisFeatureStore
.uri
- the uri of the Redis resource to connect to.cacheTimeSecs
- the cache time in seconds. See cacheTime(long, TimeUnit)
for more information.public RedisFeatureStoreBuilder(java.lang.String scheme, java.lang.String host, int port, long cacheTimeSecs) throws java.net.URISyntaxException
Components.redisFeatureStore(java.net.URI)
.RedisFeatureStore
.scheme
- the URI scheme to usehost
- the hostname to connect toport
- the port to connect tocacheTimeSecs
- the cache time in seconds. See cacheTime(long, TimeUnit)
for more information.java.net.URISyntaxException
- if the URI is not validpublic RedisFeatureStoreBuilder caching(FeatureStoreCacheConfig caching)
FeatureStoreCacheConfig.DEFAULT
. To disable it, pass
FeatureStoreCacheConfig.disabled()
to this method.caching
- a FeatureStoreCacheConfig
object specifying caching parameterspublic RedisFeatureStoreBuilder refreshStaleValues(boolean enabled)
caching(FeatureStoreCacheConfig)
and
FeatureStoreCacheConfig.staleValuesPolicy(com.launchdarkly.client.FeatureStoreCacheConfig.StaleValuesPolicy)
.FeatureStoreCacheConfig.StaleValuesPolicy.REFRESH
or FeatureStoreCacheConfig.StaleValuesPolicy.REFRESH_ASYNC
.enabled
- turns on lazy refresh of cached valuespublic RedisFeatureStoreBuilder asyncRefresh(boolean enabled)
caching(FeatureStoreCacheConfig)
and
FeatureStoreCacheConfig.staleValuesPolicy(com.launchdarkly.client.FeatureStoreCacheConfig.StaleValuesPolicy)
.FeatureStoreCacheConfig.StaleValuesPolicy.REFRESH_ASYNC
.enabled
- turns on asynchronous refresh of cached values (only if refreshStaleValues(boolean)
is also true)public RedisFeatureStoreBuilder prefix(java.lang.String prefix)
prefix
- the namespace prefixpublic RedisFeatureStoreBuilder cacheTime(long cacheTime, java.util.concurrent.TimeUnit timeUnit)
caching(FeatureStoreCacheConfig)
and FeatureStoreCacheConfig.ttl(long, TimeUnit)
.FeatureStoreCacheConfig.DEFAULT
.cacheTime
- the time value to cache for, or 0 to disable local cachingtimeUnit
- the time unit for the time valuepublic RedisFeatureStoreBuilder poolConfig(redis.clients.jedis.JedisPoolConfig poolConfig)
poolConfig
- the Jedis pool configuration.public RedisFeatureStoreBuilder connectTimeout(int connectTimeout, java.util.concurrent.TimeUnit timeUnit)
Protocol.DEFAULT_TIMEOUT
connectTimeout
- the timeouttimeUnit
- the time unit for the timeoutpublic RedisFeatureStoreBuilder socketTimeout(int socketTimeout, java.util.concurrent.TimeUnit timeUnit)
Protocol.DEFAULT_TIMEOUT
socketTimeout
- the socket timeouttimeUnit
- the time unit for the timeoutpublic RedisFeatureStore build()
RedisFeatureStore
based on the currently configured builder object.RedisFeatureStore
configured by this builder.public RedisFeatureStore createFeatureStore()
build()
.createFeatureStore
in interface FeatureStoreFactory
RedisFeatureStore
configured by this builder.