use of redis.clients.jedis.JedisPool in project disgear by yangbutao.
the class CacheOperation method read.
public Map<String, String> read(String host, int port, String key) throws Exception {
// host = "10.1.1.26";
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();
Map<String, String> user = jedis.hgetAll(key);
/*
* AtomicLong tmp = count.get(host); if (tmp == null) { tmp = new
* AtomicLong(0); } tmp.addAndGet(1); count.put(host, tmp);
*/
return user;
// System.out.println("********************"+count.toString());
} finally {
pool.returnResource(jedis);
}
}
use of redis.clients.jedis.JedisPool in project ignite by apache.
the class RedisProtocolSelfTest method beforeTestsStarted.
/** {@inheritDoc} */
@Override
protected void beforeTestsStarted() throws Exception {
startGrids(gridCount());
JedisPoolConfig jedisPoolCfg = new JedisPoolConfig();
jedisPoolCfg.setMaxWaitMillis(10000);
jedisPoolCfg.setMaxIdle(100);
jedisPoolCfg.setMinIdle(1);
jedisPoolCfg.setNumTestsPerEvictionRun(10);
jedisPoolCfg.setTestOnBorrow(true);
jedisPoolCfg.setTestOnReturn(true);
jedisPoolCfg.setTestWhileIdle(true);
jedisPoolCfg.setTimeBetweenEvictionRunsMillis(30000);
pool = new JedisPool(jedisPoolCfg, HOST, PORT, 10000);
}
Aggregations