1:修改实时统计配置向集群同步时没有将哨兵的连接关闭导致资源被占满的问题
2:修改从redis获取自增长值时可能存在的redis连接未关闭的情况
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user