use of redis.clients.jedis.JedisPool in project cachecloud by sohutv.
the class JedisPoolTest method customClientName.
@Test
public void customClientName() {
JedisPool pool0 = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000, "foobared", 0, "my_shiny_client_name");
Jedis jedis = pool0.getResource();
assertEquals("my_shiny_client_name", jedis.clientGetname());
jedis.close();
pool0.destroy();
assertTrue(pool0.isClosed());
}
use of redis.clients.jedis.JedisPool in project cachecloud by sohutv.
the class JedisPoolTest method testAddObject.
@Test
public void testAddObject() {
JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000);
pool.addObjects(1);
assertEquals(pool.getNumIdle(), 1);
pool.destroy();
}
use of redis.clients.jedis.JedisPool in project cachecloud by sohutv.
the class JedisPoolTest method selectDatabaseOnActivation.
@Test
public void selectDatabaseOnActivation() {
JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000, "foobared");
Jedis jedis0 = pool.getResource();
assertEquals(0, jedis0.getDB());
jedis0.select(1);
assertEquals(1, jedis0.getDB());
jedis0.close();
Jedis jedis1 = pool.getResource();
assertTrue("Jedis instance was not reused", jedis1 == jedis0);
assertEquals(0, jedis1.getDB());
jedis1.close();
pool.destroy();
assertTrue(pool.isClosed());
}
use of redis.clients.jedis.JedisPool in project cachecloud by sohutv.
the class JedisPoolTest method checkResourceIsCloseable.
@Test
public void checkResourceIsCloseable() {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(1);
config.setBlockWhenExhausted(false);
JedisPool pool = new JedisPool(config, hnp.getHost(), hnp.getPort(), 2000, "foobared");
Jedis jedis = pool.getResource();
try {
jedis.set("hello", "jedis");
} finally {
jedis.close();
}
Jedis jedis2 = pool.getResource();
try {
assertEquals(jedis, jedis2);
} finally {
jedis2.close();
}
}
use of redis.clients.jedis.JedisPool in project cachecloud by sohutv.
the class JedisPoolTest method checkPoolRepairedWhenJedisIsBroken.
@Test
public void checkPoolRepairedWhenJedisIsBroken() {
JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort());
Jedis jedis = pool.getResource();
jedis.auth("foobared");
jedis.quit();
jedis.close();
jedis = pool.getResource();
jedis.auth("foobared");
jedis.incr("foo");
jedis.close();
pool.destroy();
assertTrue(pool.isClosed());
}
Aggregations