mmcgrana/clj-redis — pull request #10 by ptaoussanis (2011-12-29 09:40:29+00:00)
Title: Large, breaking change: refactored clj-redis.client

Hi Mark,

This is an attempt to bring together some of the better bits of clj-redis and redis-clojure. I've chatted briefly with Tavis (the maintainer of redis-clojure) and I believe he's open to the idea of consolidating efforts behind Jedis.

The biggest change here is the use of a thread-local connection binding for all commands. Redis commands now need to be called within the context of the (with-redis) macro.

Benefits of this approach include:
1. Performance (less leasing is necessary in multi-command operations).
2. Less repetition (the pool doesn't need to be provided for every command).
3. Easier tooling (things like pipelining are easier to wrap if connection leasing is outside of the per-command context). I'd guess this might also help with the clustering/sharding story in future.
4. Easier binary interop (the same pool can service both Jedis and BinaryJedis operations and the reduction in type hinting should make this much easier).

I've also added some skeletons for stuff like sorting and pipelining from redis-clojure, but these still need to be properly translated.

I have *not* tested this thoroughly and it's quite possible I've introduced some new bugs. The old unit tests are passing but there's obviously need for new ones. Again, redis-clojure would probably be a good source for scavenging here.

Any thoughts?

--
Peter Taoussanis