Skip to content

Commit

Permalink
Merge pull request #918 from tgxworld/fix_exists
Browse files Browse the repository at this point in the history
Fix `Redis#exists?` to return boolean value for multiple key match.
  • Loading branch information
byroot committed Jun 10, 2020
2 parents 850ab84 + 525a93e commit 8982fa2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/redis.rb
Expand Up @@ -584,7 +584,9 @@ def _exists(*keys)
# @return [Boolean]
def exists?(*keys)
synchronize do |client|
client.call([:exists, *keys], &Boolify)
client.call([:exists, *keys]) do |value|
value > 0
end
end
end

Expand Down
4 changes: 4 additions & 0 deletions test/lint/value_types.rb
Expand Up @@ -40,6 +40,10 @@ def test_exists?
r.set("{1}foo", "s1")

assert_equal true, r.exists?("{1}foo")

r.set("{1}bar", "s1")

assert_equal true, r.exists?("{1}foo", "{1}bar")
end

def test_type
Expand Down

0 comments on commit 8982fa2

Please sign in to comment.