use of org.apache.commons.pool2.impl.GenericObjectPoolConfig in project jedis by xetorthio.
the class ShardedJedisPoolTest method shouldNotShareInstances.
@Test
public void shouldNotShareInstances() {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(2);
ShardedJedisPool pool = new ShardedJedisPool(config, shards);
ShardedJedis j1 = pool.getResource();
ShardedJedis j2 = pool.getResource();
assertNotSame(j1.getShard("foo"), j2.getShard("foo"));
}
use of org.apache.commons.pool2.impl.GenericObjectPoolConfig in project jedis by xetorthio.
the class ShardedJedisPoolTest method checkJedisIsReusedWhenReturned.
@Test
public void checkJedisIsReusedWhenReturned() {
ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
ShardedJedis jedis = pool.getResource();
jedis.set("foo", "0");
jedis.close();
jedis = pool.getResource();
jedis.incr("foo");
jedis.close();
pool.destroy();
}
use of org.apache.commons.pool2.impl.GenericObjectPoolConfig in project jedis by xetorthio.
the class ShardedJedisPoolTest method checkConnections.
@Test
public void checkConnections() {
ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
ShardedJedis jedis = pool.getResource();
jedis.set("foo", "bar");
assertEquals("bar", jedis.get("foo"));
jedis.close();
pool.destroy();
}
use of org.apache.commons.pool2.impl.GenericObjectPoolConfig in project jetcache by alibaba.
the class RedisCacheTest method testSimplePool.
@Test
public void testSimplePool() throws Exception {
GenericObjectPoolConfig pc = new GenericObjectPoolConfig();
pc.setMinIdle(2);
pc.setMaxIdle(10);
pc.setMaxTotal(10);
JedisPool pool = new JedisPool(pc, "localhost", 6379);
testWithPool(pool);
}
use of org.apache.commons.pool2.impl.GenericObjectPoolConfig in project jetcache by alibaba.
the class RedisCacheTest method testSentinel.
@Test
public void testSentinel() throws Exception {
GenericObjectPoolConfig pc = new GenericObjectPoolConfig();
pc.setMinIdle(2);
pc.setMaxIdle(10);
pc.setMaxTotal(10);
Set<String> sentinels = new HashSet<>();
sentinels.add("127.0.0.1:26379");
sentinels.add("127.0.0.1:26380");
sentinels.add("127.0.0.1:26381");
JedisSentinelPool pool = new JedisSentinelPool("mymaster", sentinels, pc);
testWithPool(pool);
}
Aggregations