mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 18:51:08 +08:00
FIX: add support for pipelined and multi redis commands (#16682)
Latest redis interoduces a block form of multi / pipelined, this was incorrectly passed through and not namespaced. Fix also updates logster, we held off on upgrading it due to missing functions
This commit is contained in:
@ -14,9 +14,9 @@ class DiscourseRedis
|
||||
GlobalSetting.redis_config
|
||||
end
|
||||
|
||||
def initialize(config = nil, namespace: true)
|
||||
def initialize(config = nil, namespace: true, raw_redis: nil)
|
||||
@config = config || DiscourseRedis.config
|
||||
@redis = DiscourseRedis.raw_connection(@config.dup)
|
||||
@redis = raw_redis || DiscourseRedis.raw_connection(@config.dup)
|
||||
@namespace = namespace
|
||||
end
|
||||
|
||||
@ -150,6 +150,26 @@ class DiscourseRedis
|
||||
Cache.new
|
||||
end
|
||||
|
||||
def multi
|
||||
if block_given?
|
||||
@redis.multi do |transaction|
|
||||
yield DiscourseRedis.new(@config, namespace: @namespace, raw_redis: transaction)
|
||||
end
|
||||
else
|
||||
@redis.multi
|
||||
end
|
||||
end
|
||||
|
||||
def pipelined
|
||||
if block_given?
|
||||
@redis.pipelined do |transaction|
|
||||
yield DiscourseRedis.new(@config, namespace: @namespace, raw_redis: transaction)
|
||||
end
|
||||
else
|
||||
@redis.pipelined
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def remove_namespace(key)
|
||||
|
Reference in New Issue
Block a user