1:修改实时统计配置向集群同步时没有将哨兵的连接关闭导致资源被占满的问题

2:修改从redis获取自增长值时可能存在的redis连接未关闭的情况
This commit is contained in:
renkaige
2019-02-13 16:16:41 +08:00
parent c462477762
commit db24069faa
2 changed files with 48 additions and 30 deletions

View File

@@ -76,9 +76,17 @@ public class JedisUtils {
* @return long 相加后的值
*/
public static long incrBy(String key, long number, int redisDb) {
Jedis jedis = getResource(redisDb);
long len = jedis.incrBy(key, number);
returnResource(jedis);
Jedis jedis = null;
long len = 0l;
try {
jedis = getResource(redisDb);
len = jedis.incrBy(key, number);
} catch (Exception e) {
throw new ServiceRuntimeException("" + redisDb + "号redisDB中获取自增值" + key + "失败",
RestBusinessCode.KeyNotExistsInRedis.getValue());
} finally {
returnResource(jedis);
}
return len;
}