博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
修改Jedis2.1版本 多线程并发错误。
阅读量:4215 次
发布时间:2019-05-26

本文共 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/

你可能感兴趣的文章
【HTML5/CSS/JS】开发跨平台应用工具的选择(三)
查看>>
【心灵鸡汤】Give it five minutes不要让一个好主意随风而去
查看>>
【React Native】Invariant Violation: Application AwesomeProject has not been registered
查看>>
【ReactNative】真机上无法调试 could not connect to development server
查看>>
【XCode 4.6】常用快捷键 特别是格式化代码ctrl+i
查看>>
【iOS游戏开发】icon那点事 之 图标设计(三)
查看>>
【IOS游戏开发】之测试发布(Distribution)
查看>>
【IOS游戏开发】之IPA破解原理
查看>>
【一天一道LeetCode】#45. Jump Game II
查看>>
【一天一道LeetCode】#56. Merge Intervals
查看>>
【一天一道LeetCode】#58. Length of Last Word
查看>>
【一天一道LeetCode】#59. Spiral Matrix II
查看>>
【一天一道LeetCode】#30. Substring with Concatenation of All Words
查看>>
【一天一道LeetCode】#60. Permutation Sequence.
查看>>
【unix网络编程第三版】阅读笔记(二):套接字编程简介
查看>>
【一天一道LeetCode】#116. Populating Next Right Pointers in Each Node
查看>>
【一天一道LeetCode】#118. Pascal's Triangle
查看>>
JAVA实现文件树
查看>>
ebay api - GetUserDisputes 函数
查看>>
ebay api GetMyMessages 函数
查看>>