-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Jedis.close() should return Jedis to pool instead of closing it #562
Comments
Mmm... this is tricky. I wonder if flagging the |
How about wrapping it? |
I'm planning to implement PooledJedis wrapping Jedis class and provide close(). |
Great. Sounds right to me. |
Jedis and BinaryJedis is easy to implement close() because it just have to call disconnect(). |
@secondorderpolynomial Thanks for triple check! |
I missed the discussion around this. On Fri, Feb 21, 2014 at 6:03 PM, Jungtaek Lim [email protected]:
|
@xetorthio Jedis needs to keep track of pool instance (their source) to return itself to pool. And I will try to implement PooledJedisCommand, same thing to JedisClusterCommand. It makes us easy to implement new things should applied to all commands. |
Need to see hpw the usage will end up.
|
@xetorthio I think it would be right for Jedis to NOT have the notion of whether or not it is a pooled resource. @HeartSaVioR Valid point about returnResource vs. returnBrokenResource. Is it always possible for PooledJedis/PooledJedisCommand to accurately determine if a connection is broken, or would it require the user (of the code) to mark Jedis as broken? Praveen |
The thing here is the usage, impact on the api and impact on the code.
|
@secondorderpolynomial @xetorthio I agree @secondorderpolynomial . And PooledJedis would 100% compatible to Jedis (should make it). All things are not 100% sure, so I wish to try implementing on it without talk to others, but I finally couldn't. ;) Thank you all! |
@xetorthio I missed to reply your comment. |
@secondorderpolynomial @xetorthio |
Just a thought, I agree on creating a class PooledJedis that inherits Jedis. It can just override method close() to check connection by calling isConnected() to decide either to call returnResource()/returnBrokenResource(). You also need to add method (e.g.) destroy() to PooledJedis to call its super method close() to actually close the connection. Therefore, there need not be major change of code in Jedis class or any change for that matter. Sorry for the late response. |
@andekaputra I also did think it just needs small changes. It extends generic parameterized and its field (internalPool) is also generic parameterized. |
Closing resolved issue. |
This issue was closed by won't fix. But notice that #909 and 6701b07 have merged to use The latest usage is following. Make sure everybody knows about that 😃
|
@tobegit3hub You are right. I will open a issue to fix it. |
@tobegit3hub done. You can follow it here: #935 |
@tobegit3hub I don't quite understand your comment. returnBrokenResource and returnResource will be removed starting from 3.0 as we don't need to maintain them anymore. |
You're right @marcosnils and I misunderstood about the feature of It took us a few days to know about this. Thanks. |
Hi I am very new to Jedis and trying to use it in my application. package com.redis.config; import org.springframework.beans.factory.annotation.Autowired; import redis.clients.jedis.JedisPoolConfig; @configuration
@bean
} @bean @bean
} } I am using @Cacheable with the below method signature in my service @Cacheable(value = "user" , key = "#Id") And below is the controller I am using @RequestMapping(value = "/getUserDetails" , method=RequestMethod.POST, produces=MediaType.APPLICATION_JSON_VALUE)
I am getting the below exception at Line user= userService.readUser(Id); The error occured with the first time only when hitting the url Any help would be appreciable. |
Please ask this question in the mailing list. github is used for design discussions and bugs mainly. |
What steps will reproduce the problem?
What is the expected output? What do you see instead?
Jedis was accessed from a pool. Jedis should be returned to the pool. Instead the connection is closed.
This makes it impossible to use Jedis in a try-with-resource without closing it.
Also, findbugs complains if close isn't called on Jedis, as it is a Closable.
What version of the product are you using? On what operating system?
2.4.0
OS: irrelevant
Please provide any additional information below.
I think it's stylistically terse to use Jedis with a try-with-resource. This behavior would be similar to JDBC DataSource connection pooling, and I am assuming, easy enough to implement.
The text was updated successfully, but these errors were encountered: