provide a reset() method to read all remaining data #213

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
Contributor

raszi commented Sep 26, 2011

It would be useful to have a reset() method in Jedis client.

It could be called before returning a shared Jedis client to the pool, or borrowing it again.

Contributor

raszi commented Sep 26, 2011

All tests passed.

Owner

xetorthio commented Dec 13, 2011

what would be the use case of this? can you provide an example?

Contributor

raszi commented Dec 14, 2011

Jedis client has an inner state, which cannot be altered from outside. So if the client sent some bytes to the server and a timeout occurred, then it is impossible to reset this client to a normal state without this method.

Owner

xetorthio commented Dec 14, 2011

Ok. In that case you'll get a JedisConnectionException. Whenever you get this excption you are supposed to returnBrokenResource instead of returnResource.
This way this resource can be deleted and a new one is created.
Do you still think this is necessary?

Contributor

raszi commented Dec 14, 2011

But the timeouted client could be restored with this reset() method, and creating a new object with connecting and selecting database could take more resource than a simple reset.

If you don't want to use reset() and return just a broken resource it depends on you, but this would take no harm and provides a better API, because the inner state could be reset.

Owner

xetorthio commented Dec 14, 2011

In this case you are doing a getAll on client, what happen if connection
was closed? in that case any read on the socket will throw an error, and
every call to reset will throw an error.

2011/12/14 KARASZI Istvn <
reply@reply.github.com

But the timeouted client could be restored with this reset() method, and
creating a new object with connecting and selecting database could take
more resource than a simple reset.

If you don't want to use reset() and return just a broken resource it
depends on you, but this would take no harm and provide a better API,
because the inner state could be reset.


Reply to this email directly or view it on GitHub:
#213 (comment)

Contributor

raszi commented Dec 14, 2011

sending requests on a closed connection always cause exceptions don't they?

so reset() won't differ from any other command

Collaborator

HeartSaVioR commented May 31, 2015

I already introduced resetState() which covers more internal states.
Marking this as invalid. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment