Skip to content

SMISMEMBER support #1667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1768,6 +1768,14 @@ def smembers(self, name):
"""Return all members of the set ``name``"""
return self.execute_command('SMEMBERS', name)

def smismember(self, name, values, *args):
"""
Return whether each value in ``values`` is a member of the set ``name``
as a list of ``bool`` in the order of ``values``
"""
args = list_or_args(values, args)
return self.execute_command('SMISMEMBER', name, *args)

def smove(self, src, dst, value):
"""Move ``value`` from set ``src`` to set ``dst`` atomically"""
return self.execute_command('SMOVE', src, dst, value)
Expand Down
7 changes: 7 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,13 @@ def test_smembers(self, r):
r.sadd('a', '1', '2', '3')
assert r.smembers('a') == {b'1', b'2', b'3'}

@skip_if_server_version_lt('6.2.0')
def test_smismember(self, r):
r.sadd('a', '1', '2', '3')
result_list = [True, False, True, True]
assert r.smismember('a', '1', '4', '2', '3') == result_list
assert r.smismember('a', ['1', '4', '2', '3']) == result_list

def test_smove(self, r):
r.sadd('a', 'a1', 'a2')
r.sadd('b', 'b1', 'b2')
Expand Down