Skip to content

Commit 0ef2fc5

Browse files
committed
Minimal Sentinel example added.
1 parent a4fbad6 commit 0ef2fc5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

examples/sentinel.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'redis'
2+
3+
Sentinels = [{:host => "127.0.0.1", :port => 26379},
4+
{:host => "127.0.0.1", :port => 26380}]
5+
r = Redis.new(:url => "sentinel://mymaster", :sentinels => Sentinels, :role => :master)
6+
7+
# Set keys into a loop.
8+
#
9+
# The example traps errors so that you can actually try to failover while
10+
# running the script to see redis-rb reconfiguring.
11+
(0..1000000).each{|i|
12+
begin
13+
r.set(i,i)
14+
puts i
15+
rescue
16+
puts "ERROR #{i}"
17+
end
18+
sleep(0.01)
19+
}

0 commit comments

Comments
 (0)