After a few weeks with very stable release candidates, we have just pushed version 2.0.0. Here’s a quick rundown on what’s new with the Ruby client for Redis:
Explicit > Implicit
The previous version of the client relied on method_missing to execute commands against Redis. While this was great for quickly putting together a simple client, it proved insufficient for more advanced commands like pub/sub, blocking pop, etc. Plus, relying on this technique lead to longer and more branched methods as new features were added to Redis.
The new version explicitly defines each command as a method in the Redis class. We strongly believe that explicit beats implicit. This way it’s much easier to follow what is going on for each command. We did leave method_missing in there because it’s a nice way of being able to run simple commands that are not yet known to the client, but we’ll keep adding new commands as needed.
A nice consequence of this change is that the complexity of the code was reduced drastically. Many branches were removed in favor of separate, smaller methods (this is something that could only be done with an explicit method for each command).
New protocol
This version uses the new protocol only. It means people running a Redis version older than 1.2 will be stuck with the 1.0 branch. This multi-bulk protocol is binary safe and will be the only one available once Redis 2.0 is released, for which a release candidate is expected soon.
Faster!
One of our concerns when refactoring was the impact on performance this decoupling would bring. We agreed that a good goal would be to have the new version performing at least as fast as the old one. To our surprise –and probably because of the removal of branches, hash look-ups and by avoiding method_missing– the new version performed even better.
Before:
$ ruby -Ilib benchmarking/speed.rb
7.88 Kops
After:
$ ruby -Ilib benchmarking/speed.rb
8.79 Kops
The higher the number, the better. It means that the new version executes almost a thousand operations more per second.
Redis::Distributed
The old client shipped with DistRedis, which included a hashring algorithm and supported a small subset of operations. As it wasn’t tested or documented, we started by defining all the test cases and proceeded to implement them. Some operations are impossible in a distributed scenario, but we would cover a lot of interesting cases and it is now a very reliable tool. Check the testing suite to see the range of commands that are now possible.
Support/Bugs/Help
Jump to IRC if you need instant help. We are most of the time available at #redis-rb on Freenode. If nobody can help you there, try #redis. You can also create an issue on GitHub, or fork the project and send a patch directly.

{ 4 comments… read them below or add one }
Very nice work on all of this guys. I highly approve and appreciate the refactoring you guys did, nice work!
@Ezra: Thanks!
I have been using the redis-rb gem all the time lately. Thanks for all your hard work on the new release.
Users should note that in older redis-rb the info method returned a hash with symbol keys, and in 2.0 it returns a hash with string keys.