diff --git a/lib/redis.rb b/lib/redis.rb index 2a1642d8e..52509569f 100644 --- a/lib/redis.rb +++ b/lib/redis.rb @@ -1524,6 +1524,19 @@ def sismember(key, member) end end + # Determine if multiple values are members of a set. + # + # @param [String] key + # @param [String, Array] members + # @return [Array] + def smismember(key, *members) + synchronize do |client| + client.call([:smismember, key, *members]) do |reply| + reply.map(&Boolify) + end + end + end + # Get all the members in a set. # # @param [String] key diff --git a/lib/redis/distributed.rb b/lib/redis/distributed.rb index 7586139bb..1056856e8 100644 --- a/lib/redis/distributed.rb +++ b/lib/redis/distributed.rb @@ -552,6 +552,11 @@ def sismember(key, member) node_for(key).sismember(key, member) end + # Determine if multiple values are members of a set. + def smismember(key, *members) + node_for(key).smismember(key, *members) + end + # Get all the members in a set. def smembers(key) node_for(key).smembers(key) diff --git a/test/lint/sets.rb b/test/lint/sets.rb index 56c167de2..c799ae678 100644 --- a/test/lint/sets.rb +++ b/test/lint/sets.rb @@ -88,6 +88,18 @@ def test_sismember assert_equal false, r.sismember("foo", "s2") end + def test_smismember + target_version("6.2") do + assert_equal [false], r.smismember("foo", "s1") + + r.sadd "foo", "s1" + assert_equal [true], r.smismember("foo", "s1") + + r.sadd "foo", "s3" + assert_equal [true, false, true], r.smismember("foo", "s1", "s2", "s3") + end + end + def test_smembers assert_equal [], r.smembers("foo")