From 525a93edbb2e65ea94634f30153d38cf85e3fe7f Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Wed, 10 Jun 2020 15:29:41 +0800 Subject: [PATCH] Fix `Redis#exists?` to return boolean value for multiple key match. --- lib/redis.rb | 4 +++- test/lint/value_types.rb | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/redis.rb b/lib/redis.rb index a279bfb40..97e263fdc 100644 --- a/lib/redis.rb +++ b/lib/redis.rb @@ -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 diff --git a/test/lint/value_types.rb b/test/lint/value_types.rb index 59212fed0..c2ca2552f 100644 --- a/test/lint/value_types.rb +++ b/test/lint/value_types.rb @@ -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