Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit f7fddeb

Browse files
committed
Expose pool configuration settings for Redis
1 parent 0639564 commit f7fddeb

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

src/main/java/com/launchdarkly/client/RedisFeatureStore.java

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,56 @@ public class RedisFeatureStore implements FeatureStore {
3333
private static final String INIT_KEY = "$initialized$";
3434

3535
/**
36+
* Creates a new store instance that connects to Redis with the provided host, port, prefix, and cache timeout. Uses a default
37+
* connection pool configuration.
3638
*
3739
* @param host the host for the Redis connection
3840
* @param port the port for the Redis connection
3941
* @param prefix a namespace prefix for all keys stored in Redis
4042
* @param cacheTimeSecs an optional timeout for the in-memory cache. If set to 0, no in-memory caching will be performed
4143
*/
4244
public RedisFeatureStore(String host, int port, String prefix, long cacheTimeSecs) {
43-
pool = new JedisPool(getPoolConfig(), host, port);
45+
this(host, port, prefix, cacheTimeSecs, getPoolConfig());
46+
}
47+
48+
/**
49+
* Creates a new store instance that connects to Redis with the provided URI, prefix, and cache timeout. Uses a default
50+
* connection pool configuration.
51+
*
52+
* @param uri the URI for the Redis connection
53+
* @param prefix a namespace prefix for all keys stored in Redis
54+
* @param cacheTimeSecs an optional timeout for the in-memory cache. If set to 0, no in-memory caching will be performed
55+
*/
56+
public RedisFeatureStore(URI uri, String prefix, long cacheTimeSecs) {
57+
this(uri, prefix, cacheTimeSecs, getPoolConfig());
58+
}
59+
60+
/**
61+
* Creates a new store instance that connects to Redis with the provided URI, prefix, cache timeout, and connection pool settings.
62+
*
63+
* @param host the host for the Redis connection
64+
* @param port the port for the Redis connection
65+
* @param prefix a namespace prefix for all keys stored in Redis
66+
* @param cacheTimeSecs an optional timeout for the in-memory cache. If set to 0, no in-memory caching will be performed
67+
* @param poolConfig an optional pool config for the Jedis connection pool
68+
*/
69+
public RedisFeatureStore(String host, int port, String prefix, long cacheTimeSecs, JedisPoolConfig poolConfig) {
70+
pool = new JedisPool(poolConfig, host, port);
4471
setPrefix(prefix);
4572
createCache(cacheTimeSecs);
4673
createInitCache(cacheTimeSecs);
4774
}
4875

4976
/**
50-
* Creates a new store instance that connects to Redis with the provided URI, prefix, and cache timeout.
77+
* Creates a new store instance that connects to Redis with the provided URI, prefix, cache timeout, and connection pool settings.
5178
*
5279
* @param uri the URI for the Redis connection
5380
* @param prefix a namespace prefix for all keys stored in Redis
5481
* @param cacheTimeSecs an optional timeout for the in-memory cache. If set to 0, no in-memory caching will be performed
82+
* @param poolConfig an optional pool config for the Jedis connection pool
5583
*/
56-
public RedisFeatureStore(URI uri, String prefix, long cacheTimeSecs) {
57-
pool = new JedisPool(getPoolConfig(), uri);
84+
public RedisFeatureStore(URI uri, String prefix, long cacheTimeSecs, JedisPoolConfig poolConfig) {
85+
pool = new JedisPool(poolConfig, uri);
5886
setPrefix(prefix);
5987
createCache(cacheTimeSecs);
6088
createInitCache(cacheTimeSecs);
@@ -283,7 +311,7 @@ private FeatureRep<?> getRedis(String key) {
283311
}
284312
}
285313

286-
private final JedisPoolConfig getPoolConfig() {
314+
private static final JedisPoolConfig getPoolConfig() {
287315
JedisPoolConfig config = new JedisPoolConfig();
288316
return config;
289317
}

0 commit comments

Comments
 (0)