本文共 984 字,大约阅读时间需要 3 分钟。
修改方法:
1.使用Jedis2.1版本需要做如下修改:
*给整个jedis操作过程加try。
*catch所有异常,在catch中添加:RedisUtil.getInstance().returnBrokenResource(jedis);
*finally 中 RedisUtil.getInstance().returnJedis(jedis);
例:
public static Object addWaitForPrepare(String key) {
Jedis jedis = RedisUtil.getInstance().getJedis();
String value = null;
try {
if (Config.parserPlatformConfigXML.getTenant().isSingleTenant()) {
jedis.set(key, "Yes");
logger.debug("Set_redis_key: {}, value: Yes", key);
} else {
jedis.hset(Keys.format(Keys.KEYS_SYSCONFIG_PREFIX, CloudDataSource.currentTenant()), key, "Yes");
}
} catch (Exception e) {
logger.warn("addWaitForPrepare_TException,there is no key:{}", key);
RedisUtil.getInstance().returnBrokenResource(jedis);
} finally {
RedisUtil.getInstance().returnJedis(jedis);
}
return value;
}
2.使用Jedis2.7版本需要检查:
*this.pool.returnResource(jedis); 改为:jedis.close();
*config.setMaxActive(maxActive); 改为:config.setMaxTotal(maxActive);
*config.setMaxWait(maxWait); 改为config.setMaxWaitMillis(maxWait);
转载地址:http://fqnmi.baihongyu.com/