use of redis.clients.jedis.ShardedJedisPool in project jedis by xetorthio.
the class ShardedJedisPoolTest method checkResourceIsCloseable.
@Test
public void checkResourceIsCloseable() throws URISyntaxException {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(1);
config.setBlockWhenExhausted(false);
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
shards.add(new JedisShardInfo(new URI("redis://:foobared@localhost:6380")));
shards.add(new JedisShardInfo(new URI("redis://:foobared@localhost:6379")));
ShardedJedisPool pool = new ShardedJedisPool(config, shards);
ShardedJedis jedis = pool.getResource();
try {
jedis.set("hello", "jedis");
} finally {
jedis.close();
}
ShardedJedis jedis2 = pool.getResource();
try {
assertEquals(jedis, jedis2);
} finally {
jedis2.close();
}
}
use of redis.clients.jedis.ShardedJedisPool in project oxCore by GluuFederation.
the class RedisShardedProvider method create.
public void create() {
try {
LOG.debug("Starting RedisShardedProvider ... configuration:" + redisConfiguration);
JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxTotal(1000);
poolConfig.setMinIdle(2);
pool = new ShardedJedisPool(poolConfig, shards(redisConfiguration.getServers()));
testConnection();
LOG.debug("RedisShardedProvider started.");
} catch (Exception e) {
LOG.error("Failed to start RedisShardedProvider.");
throw new IllegalStateException("Error starting RedisShardedProvider", e);
}
}
Aggregations