Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使redis支持password。 #135

Merged
merged 2 commits into from
May 27, 2016
Merged

使redis支持password。 #135

merged 2 commits into from
May 27, 2016

Conversation

yuwgle
Copy link

@yuwgle yuwgle commented May 27, 2016

使redis支持password。
注:backup必须使用相同的password,否则无法连接。

感谢@maczam 同学的提交,并集成了 @maczam 同学修复的 jedis断点重连时的问题。

yuwgle added 2 commits May 27, 2016 11:17
 backup必须使用相同的password,否则无法连接。
@li-shen li-shen merged commit 8ee2f9d into dangdangdotcom:master May 27, 2016
@zjulbj
Copy link

zjulbj commented Mar 30, 2017

异常处理用try with resource是不是好点

@yuwgle
Copy link
Author

yuwgle commented Jun 25, 2017

@zjulbj

首先,JedisPool类,并没有实现AutoCloseable这个接口。
只有实现了java.lang.AutoCloseable接口,或者java.io.Closable(实际上继随自java.lang.AutoCloseable)接口的对象,才会自动调用其close()函数。

而且,这里返回连接有两种方式,不是简单的关闭连接:

if(isBroken){
       jedisPool.returnBrokenResource(jedis);
} else {
       jedisPool.returnResource(jedis);
 }

如果新版JedisPool实现 AutoCloseable接口并满足这样的需求的话,是可以改成 try with resources的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants