Skip to content

Instantly share code, notes, and snippets.

@ZachMassia
Created December 12, 2012 21:32
Show Gist options
  • Save ZachMassia/4271817 to your computer and use it in GitHub Desktop.
Save ZachMassia/4271817 to your computer and use it in GitHub Desktop.
redis test class
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