mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +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:
@ -17,6 +17,45 @@ describe DiscourseRedis do
|
||||
raw_redis.flushdb
|
||||
end
|
||||
|
||||
describe 'pipelined / multi' do
|
||||
let(:redis) { DiscourseRedis.new }
|
||||
|
||||
it 'should support multi commands' do
|
||||
val = redis.multi do |transaction|
|
||||
transaction.set 'foo', 'bar'
|
||||
transaction.set 'bar', 'foo'
|
||||
transaction.get 'bar'
|
||||
end
|
||||
|
||||
expect(raw_redis.get('foo')).to eq(nil)
|
||||
expect(raw_redis.get('bar')).to eq(nil)
|
||||
expect(redis.get('foo')).to eq('bar')
|
||||
expect(redis.get('bar')).to eq('foo')
|
||||
|
||||
expect(val).to eq(["OK", "OK", "foo"])
|
||||
end
|
||||
|
||||
it 'should support pipelined commands' do
|
||||
set, incr = nil
|
||||
val = redis.pipelined do |pipeline|
|
||||
set = pipeline.set "foo", "baz"
|
||||
incr = pipeline.incr "baz"
|
||||
end
|
||||
|
||||
expect(val).to eq(["OK", 1])
|
||||
|
||||
expect(set.value).to eq("OK")
|
||||
expect(incr.value).to eq(1)
|
||||
|
||||
expect(raw_redis.get('foo')).to eq(nil)
|
||||
expect(raw_redis.get('baz')).to eq(nil)
|
||||
|
||||
expect(redis.get('foo')).to eq("baz")
|
||||
expect(redis.get('baz')).to eq("1")
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when namespace is enabled' do
|
||||
let(:redis) { DiscourseRedis.new }
|
||||
|
||||
|
Reference in New Issue
Block a user