Use global or constant variable in Ruby/Rails? -
say have connection memcache or redis... style preferred , why?
memcache = memcache.new(...) redis = redis.new(...) or
$memcache = memcache.new(...) $redis = redis.new(...)
you might want use redis.current more info here
for example, in initializer:
redis.current = redis.new(host: 'localhost', port: 6379) and in other classes:
def stars redis.smembers("stars") end private def redis redis.current end
Comments
Post a Comment