Created
January 23, 2014 00:55
-
-
Save shooley/8570732 to your computer and use it in GitHub Desktop.
Redis Helper Module
This file contains 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
module RedisHelper | |
def is_redis_open? | |
begin | |
Timeout::timeout(1) do | |
begin | |
s = TCPSocket.new(REDIS_CONFIG['server_url'], 6379) | |
s.close | |
return true | |
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH | |
return false | |
end | |
end | |
rescue Timeout::Error | |
end | |
return false | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment