Gem Version Build Status

A production ready Redis cluster client for Ruby.

Renoir provides compatible interface with redis-rb.


Add this line to your application's Gemfile:

gem 'renoir'

And then execute:

$ bundle

Or install it yourself as:

$ gem install renoir


You can request to a Redis cluster by instantiating Renoir::Client with cluster_nodes option.

require 'renoir'

rc = [''])

puts rc.set('hoge', 123) #=> OK
puts rc.set('fuga', 456) #=> OK
puts rc.get('hoge') #=> 123
puts rc.get('fuga') #=> 456

Options for redis-rb could also be passed as an argument:

rc =
  cluster_nodes: [''],

  # redis-rb options
  timeout: 100,
  password: 'password',
  driver: :hiredis


Command pipelining is supported although "future" variable is not available at this point.

rc.pipeliend do |pipeline|
  pipeline.set('hoge{1}', 123)
# => ["OK", "123", nil]

If pipelined commands use different slot of key, it fails without dispatching command.

You can also execute commands atomically with #multi:

rc.multi do |pipeline|
  pipeline.set('hoge{1}', 123)
# => ["OK", "123", nil]

Dispatch command to nodes directly

Renoir dispatches a command only if a slot is determined by the command. This also includes no-keys commands like KEYS, BGSAVE and so on.

If you would like to dispatch such commands, Renoir::Client#each_node could be used:

keys = []
rc.each_node do |node|
  keys += node.keys('test_*')
p keys


Following options could be passed to Renoir::Client#new:

cluster_nodes (required)

Array of cluster node locations. At least one location must be specified.

A location could be String, Array or Hash:

cluster_nodes: [
  ['', 30002],
  { host:, port: 30003 }


Max number of redirections. Defaults to 10.


Max number of acceptable connection errors. Defaults to 5.

connect_retry_interval, connect_retry_random_factor

Options for adjusting an interval of retry that a client tries to reconnect to same node when connection error is occurred. Defaults to 0.001 (sec) and 0.1 respectively.

A retry interval is proportional to a random value sampled from [connect_retry_interval - connect_retry_random_factor, connect_retry_interval + connect_retry_random_factor].


Adapter name of internal connection that client uses to connect to Redis node. Defaults to :redis.

Available adapter is :redis so far.


After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.


The gem is available as open source under the terms of the MIT License.

The original code is from antirez/redis-rb-cluster.