mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
DEV: Fix implementation for DiscourseRedis#exists
.
This commit is contained in:
@ -208,16 +208,18 @@ class DiscourseRedis
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Remove when this has been upstreamed in https://github.com/redis/redis-rb/pull/911
|
# Implement our own because https://github.com/redis/redis-rb/issues/698 has stalled
|
||||||
def exists(*keys)
|
def exists(*keys)
|
||||||
keys.map! { |a| "#{namespace}:#{a}" } if @namespace
|
keys.map! { |a| "#{namespace}:#{a}" } if @namespace
|
||||||
|
|
||||||
DiscourseRedis.ignore_readonly do
|
DiscourseRedis.ignore_readonly do
|
||||||
@redis._client.call([:exists, *keys]) do |value|
|
@redis.synchronize do |client|
|
||||||
|
client.call([:exists, *keys]) do |value|
|
||||||
value > 0
|
value > 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def mget(*args)
|
def mget(*args)
|
||||||
args.map! { |a| "#{namespace}:#{a}" } if @namespace
|
args.map! { |a| "#{namespace}:#{a}" } if @namespace
|
||||||
|
@ -88,7 +88,6 @@ describe DiscourseRedis do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Remove when this has been upstreamed in https://github.com/redis/redis-rb/pull/911
|
|
||||||
describe '.exists' do
|
describe '.exists' do
|
||||||
it 'should return false when key is not present' do
|
it 'should return false when key is not present' do
|
||||||
expect(Discourse.redis.exists('test')).to eq(false)
|
expect(Discourse.redis.exists('test')).to eq(false)
|
||||||
|
Reference in New Issue
Block a user