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:
Sam
2022-05-10 08:19:02 +10:00
committed by GitHub
parent 919f71537e
commit 2df3c65ba9
9 changed files with 89 additions and 28 deletions

View File

@ -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)