Skip to content

Commit a4fbad6

Browse files
committed
Sentinel support documented into the README.
1 parent 8a12cc6 commit a4fbad6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,27 @@ available on [rdoc.info][rdoc].
8585

8686
[rdoc]: http://rdoc.info/github/redis/redis-rb/
8787

88+
## Sentinel support
89+
90+
Redis-rb is able to optionally fetch the current master address using
91+
[Redis Sentinel](http://redis.io/topics/sentinel). The new
92+
[Sentinel handshake protocol](http://redis.io/topics/sentinel-clients)
93+
is supported, so redis-rb when used with Sentinel will automatically connect
94+
to the new master after a failover, assuming you use a Recent version of
95+
Redis 2.8.
96+
97+
To connect using Sentinel, use:
98+
99+
```ruby
100+
Sentinels = [{:host => "127.0.0.1", :port => 26380},
101+
{:host => "127.0.0.1", :port => 26381}]
102+
r = Redis.new(:url => "sentinel://mymaster", :sentinels => Sentinels, :role => :master)
103+
```
104+
105+
* The master name, that identifies a group of Redis instances composed of a master and one or more slaves, is specified in the url parameter (`mymaster` in the example).
106+
* It is possible to optionally provide a role. The allowed roles are `master` and `slave`, and the default is `master`. When the role is `slave` redis-rb will try to fetch a list of slaves and will connect to a random slave.
107+
* When using the Sentinel support you need to specify a list of Sentinels to connect to. The list does not need to enumerate all your Sentinel instances, but a few so that if one is down redis-rb will try the next one. The client is able to remember the last Sentinel that was able to reply correctly and will use it for the next requests.
108+
88109
## Storing objects
89110

90111
Redis only stores strings as values. If you want to store an object, you

0 commit comments

Comments
 (0)