mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
Basic Heroku integration
This commit is contained in:
@ -4,8 +4,9 @@
|
||||
class DiscourseRedis
|
||||
|
||||
def initialize
|
||||
@config = YAML::load(File.open("#{Rails.root}/config/redis.yml"))[Rails.env]
|
||||
@config = YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env]
|
||||
redis_opts = {:host => @config['host'], :port => @config['port'], :db => @config['db']}
|
||||
redis_opts[:password] = @config['password'] if @config['password']
|
||||
@redis = Redis.new(redis_opts)
|
||||
end
|
||||
|
||||
@ -36,14 +37,14 @@ class DiscourseRedis
|
||||
end
|
||||
|
||||
def self.new_redis_store
|
||||
redis_config = YAML::load(File.open("#{Rails.root}/config/redis.yml"))[Rails.env]
|
||||
redis_store = ActiveSupport::Cache::RedisStore.new "redis://#{redis_config['host']}:#{redis_config['port']}/#{redis_config['cache_db']}"
|
||||
redis_config = YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env]
|
||||
redis_store = ActiveSupport::Cache::RedisStore.new "redis://#{(':' + redis_config['password'] + '@') if redis_config['password']}#{redis_config['host']}:#{redis_config['port']}/#{redis_config['cache_db']}"
|
||||
redis_store.options[:namespace] = -> { DiscourseRedis.namespace }
|
||||
redis_store
|
||||
end
|
||||
|
||||
def url
|
||||
"redis://#{@config['host']}:#{@config['port']}/#{@config['db']}"
|
||||
"redis://#{(':' + @config['password'] + '@') if @config['password']}#{@config['host']}:#{@config['port']}/#{@config['db']}"
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user