use of redis.clients.jedis.JedisPool in project jedis by xetorthio.
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 jedis by xetorthio.
the class JedisPoolTest method checkJedisIsReusedWhenReturned.
@Test
public void checkJedisIsReusedWhenReturned() {
JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort());
Jedis jedis = pool.getResource();
jedis.auth("foobared");
jedis.set("foo", "0");
jedis.close();
jedis = pool.getResource();
jedis.auth("foobared");
jedis.incr("foo");
jedis.close();
pool.destroy();
assertTrue(pool.isClosed());
}
use of redis.clients.jedis.JedisPool in project disgear by yangbutao.
the class CacheOperation method insert.
public void insert(String host, int port, String key, String mapKey, String mapValue) {
if (jredisPoolMap == null) {
jredisPoolMap = new ConcurrentHashMap<String, JedisPool>();
}
JedisPool pool = jredisPoolMap.get(host + ":" + port);
if (pool == null) {
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxActive(100);
config.setMaxIdle(20);
config.setMaxWait(1000l);
pool = new JedisPool(host, port);
jredisPoolMap.put(host + ":" + port, pool);
}
Jedis jedis = null;
try {
jedis = pool.getResource();
jedis.hset(key, mapKey, mapValue);
} finally {
pool.returnResource(jedis);
}
}
use of redis.clients.jedis.JedisPool in project disgear by yangbutao.
the class CacheOperation method insert.
public void insert(String host, int port, String key, Map<String, String> hash) {
if (jredisPoolMap == null) {
jredisPoolMap = new ConcurrentHashMap<String, JedisPool>();
}
JedisPool pool = jredisPoolMap.get(host + ":" + port);
if (pool == null) {
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxActive(100);
config.setMaxIdle(20);
config.setMaxWait(1000l);
pool = new JedisPool(host, port);
jredisPoolMap.put(host + ":" + port, pool);
}
Jedis jedis = null;
try {
jedis = pool.getResource();
jedis.hmset(key, hash);
} finally {
pool.returnResource(jedis);
}
}
use of redis.clients.jedis.JedisPool 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);
}
Aggregations