Skip to content

Instantly share code, notes, and snippets.

@Kalimaha
Last active April 23, 2016 04:07
Show Gist options
  • Select an option

  • Save Kalimaha/61d4ab06833f2ed353c7c3061ae498d0 to your computer and use it in GitHub Desktop.

Select an option

Save Kalimaha/61d4ab06833f2ed353c7c3061ae498d0 to your computer and use it in GitHub Desktop.
Application Helper
module ApplicationHelper
attr_reader :redis
@redis = nil
def init_redis
@redis = Redis.new(:host => Rails.configuration.x.redis.host,
:port => Rails.configuration.x.redis.port,
:password => Rails.configuration.x.redis.password) if @redis == nil
end
# Empty the DB. This method is used in the testing environment.
def flushdb
keys = @redis.keys('*')
@redis.del(*keys) unless keys.empty?
'OK'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment