mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
FEATURE: allow use of redis sentinel via redis_sentinels
Use: DISCOURSE_REDIS_SENTINELS and DISCOURSE_REDIS_HOST to configure redis sentinel
This commit is contained in:
@ -6,18 +6,11 @@ class DiscourseRedis
|
||||
|
||||
def self.raw_connection(config = nil)
|
||||
config ||= self.config
|
||||
redis_opts = {host: config['host'], port: config['port'], db: config['db']}
|
||||
redis_opts[:password] = config['password'] if config['password']
|
||||
Redis.new(redis_opts)
|
||||
Redis.new(config)
|
||||
end
|
||||
|
||||
def self.config
|
||||
@config ||= YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env]
|
||||
end
|
||||
|
||||
def self.url(config=nil)
|
||||
config ||= self.config
|
||||
"redis://#{(':' + config['password'] + '@') if config['password']}#{config['host']}:#{config['port']}/#{config['db']}"
|
||||
GlobalSetting.redis_config
|
||||
end
|
||||
|
||||
def initialize(config=nil)
|
||||
@ -30,10 +23,6 @@ class DiscourseRedis
|
||||
@redis
|
||||
end
|
||||
|
||||
def url
|
||||
self.class.url(@config)
|
||||
end
|
||||
|
||||
def self.ignore_readonly
|
||||
yield
|
||||
rescue Redis::CommandError => ex
|
||||
|
Reference in New Issue
Block a user