Created
October 29, 2016 01:22
-
-
Save msroot/ea23b3ac8ffc1d4663cfaed28de36b1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
redis = Redis.new(:url => 'redis://localhost:6379/1') | |
disconnected_at = nil | |
loop do | |
begin | |
if disconnected_at && (size = redis.keys('testing:*').count) | |
puts "reconnected_at #{Time.now}" | |
puts "KeysSize: #{size}" | |
break | |
end | |
redis.set("testing:#{Time.now.to_i}", 1) | |
puts "#{Time.now}=>#{redis.keys('testing:*').count}" | |
sleep 2 | |
rescue Redis::CannotConnectError, Errno::EINVAL | |
unless disconnected_at | |
disconnected_at = Time.now | |
puts "disconnected_at #{disconnected_at}" | |
end | |
retry | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment