DEV: Fix implementation for `DiscourseRedis#exists`.

This commit is contained in:
Guo Xiang Tan 2020-06-01 13:11:06 +08:00
parent 00aab49829
commit 389bdcf5ab
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
2 changed files with 5 additions and 4 deletions

View File

@ -208,13 +208,15 @@ class DiscourseRedis
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)
keys.map! { |a| "#{namespace}:#{a}" } if @namespace
DiscourseRedis.ignore_readonly do
@redis._client.call([:exists, *keys]) do |value|
value > 0
@redis.synchronize do |client|
client.call([:exists, *keys]) do |value|
value > 0
end
end
end
end

View File

@ -88,7 +88,6 @@ describe DiscourseRedis do
end
end
# Remove when this has been upstreamed in https://github.com/redis/redis-rb/pull/911
describe '.exists' do
it 'should return false when key is not present' do
expect(Discourse.redis.exists('test')).to eq(false)