Created
December 12, 2012 21:32
-
-
Save ZachMassia/4271817 to your computer and use it in GitHub Desktop.
redis test class
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
require 'redis' | |
class RedisTester | |
def initialize | |
@redis = Redis.new | |
end | |
def set(key, value) | |
if redis_is_running? | |
@redis.set key, value | |
end | |
end | |
def get(key) | |
if redis_is_running? | |
@redis.get key | |
end | |
end | |
def redis_is_running? | |
begin | |
if @redis.ping == 'PONG' | |
return true | |
end | |
rescue Redis::CannotConnectError | |
return false | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment