Provides for distribution of slave reads in a Redis cluster.
Add this line to your application's Gemfile:
gem 'redis-slave-read'
And then execute:
$ bundle
Or install it yourself as:
$ gem install redis-slave-read
Rather than using a Redis instance, create a wrapper that wraps multiple Redis connections.
master = Redis.new "localhost:6379"
slave1 = Redis.new "localhost:6389"
slave2 = Redis.new "localhost:6399"
$redis = Redis::SlaveRead::Interface::Hiredis.new(master: master, slaves: [slave1, slave2])
Make sure that your slaves are set to be slaved to the master, like slaveof localhost 6379
Now, you can treat your SlaveRead interface as a normal Redis interfaces. Reads are distributed among the slaves, and writes are always sent to the master. Writes will be propagated to slaves by the master.
$redis.set "foo", "bar"
$redis.get "foo"
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request