Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Always include redis-db in client description #53

merged 1 commit into from

2 participants


We operate in an environment with multiple databases per redis cluster. While developing and in the production console it is useful to see what database we are currently connected to.

With this patch, calls to "inspect" on "RedisFailover::Client" instances will include the database in the description. I was on the fence about omitting the db when it was nil/zero but decided to keep it in (I went with a hybrid of the "redis-rb" and "redis-cli" output).

I also created a new test in the "client_spec" for this change.


Very useful addition. Thanks!

@ryanlecompte ryanlecompte merged commit 91e3bed into from
@jzaleski jzaleski deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 2, 2013
  1. Always incldue redis-db in client description

    Jonathan W. Zaleski authored
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 1 deletion.
  1. +1 −1  lib/redis_failover/client.rb
  2. +12 −0 spec/client_spec.rb
2  lib/redis_failover/client.rb
@@ -123,7 +123,7 @@ def respond_to_missing?(method, include_private)
# @return [String] a string representation of the client
def inspect
- "#<RedisFailover::Client (master: #{master_name}, slaves: #{slave_names})>"
+ "#<RedisFailover::Client (db: #{@db.to_i}, master: #{master_name}, slaves: #{slave_names})>"
alias_method :to_s, :inspect
12 spec/client_spec.rb
@@ -54,6 +54,18 @@ def setup_zk
called.should be_true
+ describe '#inspect' do
+ it 'should always include db' do
+ opts = {:zkservers => 'localhost:1234'}
+ client =
+ client.inspect.should match('<RedisFailover::Client \(db: 0,')
+ db = '5'
+ opts.merge!(:db => db)
+ client =
+ client.inspect.should match("<RedisFailover::Client \\(db: #{db},")
+ end
+ end
context 'with :master_only false' do
it 'routes read operations to a slave' do
called = false
Something went wrong with that request. Please try again.