Skip to content

Instantly share code, notes, and snippets.

@smathy
Created July 22, 2015 23:11
Show Gist options
  • Save smathy/61f405853f7b5270d209 to your computer and use it in GitHub Desktop.
Save smathy/61f405853f7b5270d209 to your computer and use it in GitHub Desktop.
class MyRedis
def self.conn
connect unless @conn
begin
@conn.ping
rescue Redis::BaseConnectionError
raise if @tried
@tried = true
connect
retry
end
@conn
end
def self.connect
@conn = Redis.new ...whatever...
end
end
### then you just use it like
MyRedis.conn.call_redis_methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment