lib/helpers/redis.rb in gaptool-server-0.6.0.beta1 vs lib/helpers/redis.rb in gaptool-server-0.6.0

- old
+ new

@@ -1,6 +1,7 @@ require 'redis' +require 'redis-namespace' # docker links support unless ENV['REDIS_PORT_6379_TCP_ADDR'].nil? ENV['REDIS_HOST'] = ENV['REDIS_PORT_6379_TCP_ADDR'] ENV['REDIS_PORT'] = ENV['REDIS_PORT_6379_TCP_PORT'] @@ -10,10 +11,13 @@ ENV['REDIS_HOST'] = 'localhost' unless ENV['REDIS_HOST'] ENV['REDIS_PORT'] = '6379' unless ENV['REDIS_PORT'] ENV['REDIS_PASS'] = nil unless ENV['REDIS_PASS'] ENV['REDIS_DB'] = '0' unless ENV['REDIS_DB'] -$redis = Redis.new(:host => ENV['REDIS_HOST'], - :port => ENV['REDIS_PORT'].to_i, - :password => ENV['REDIS_PASS'], - :db => ENV['REDIS_DB'].to_i) +prefix = ENV.fetch('REDIS_PREFIX', 'gt') +conn = Redis.new(:host => ENV['REDIS_HOST'], + :port => ENV['REDIS_PORT'].to_i, + :password => ENV['REDIS_PASS'], + :db => ENV['REDIS_DB'].to_i) + +$redis = Redis::Namespace.new(prefix, redis: conn)