Skip to content

Commit

Permalink
return integer value for exists and multiple keys
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavoCaso committed Sep 16, 2019
1 parent 78bf940 commit aa5b22d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,11 @@ def unlink(*keys)
# @return [Boolean]
def exists(key)
synchronize do |client|
client.call([:exists, key], &Boolify)
if key.is_a?(Array)
client.call([:exists, key])
else
client.call([:exists, key], &Boolify)
end
end
end

Expand Down
12 changes: 12 additions & 0 deletions test/lint/value_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ def test_exists
assert_equal true, r.exists("foo")
end

def test_exists_multiple_keys
assert_equal 0, r.exists(["foo", "baz"])

r.set("foo", "s1")

assert_equal 1, r.exists(["foo", "baz"])

r.set("baz", "s2")

assert_equal 2, r.exists(["foo", "baz"])
end

def test_type
assert_equal "none", r.type("foo")

Expand Down

0 comments on commit aa5b22d

Please sign in to comment.