xetorthio/jedis — pull request #563 by HeartSaVioR (2014-02-23 15:56:13+00:00)
Title: Implements Closeable to Pooled Jedis & ShardedJedis (includes ShardedJedis itself)

This PR is implementation to #562.

At first, I tried to introduce JedisCommandExecutor (applying Command Pattern) and PooledJedis. (It may need for OOP.)
But after digging several hours, I found out there seems to be unavoidable break compatibility.
@xetorthio is right, awesome insight!!
I should think deeply on class structure, ROI, impact to current APIs before start to modify.

So I implement these things based on flag and cross-reference.

Btw, finally we can change source code - returning pooled resource - to follow!
It's been three months later @xetorthio said "we should find a nicer way to do this.". ;)
https://github.com/xetorthio/jedis/issues/476#issuecomment-29709755

````
Jedis jedis = pool.getResource();
try {
/// ... do stuff here ... for example
jedis.set("foo", "bar");
String foobar = jedis.get("foo");
jedis.zadd("sose", 0, "car"); jedis.zadd("sose", 0, "bike");
Set sose = jedis.zrange("sose", 0, -1);
} finally {
jedis.close();
}
/// ... when closing your application:
pool.destroy();
````

Please review and comment whatever is curious or wrong.
Thank you all! :)

Commit Log
----

* Implement Closeable from Jedis, ShardedJedis with Pooled
** resources from JedisPool, JedisSentinelPool, ShardedJedis, ShardedJedisPool
* Connection class : check whether Jedis Connection is broken
** when it's time to throw JedisConnectionException, mark Connection to broken
* Source Formatting