From b541da6b00c00f038293b596a62b5ecb6fdbbaa4 Mon Sep 17 00:00:00 2001 From: dvora-h <67596500+dvora-h@users.noreply.github.com> Date: Wed, 2 Feb 2022 13:52:34 +0200 Subject: Add support for SINTERCARD (#1859) * add sintercard * fix pr comment --- redis/commands/core.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'redis') diff --git a/redis/commands/core.py b/redis/commands/core.py index 383c635..5df9345 100644 --- a/redis/commands/core.py +++ b/redis/commands/core.py @@ -2388,6 +2388,19 @@ class SetCommands: args = list_or_args(keys, args) return self.execute_command("SINTER", *args) + def sintercard(self, numkeys: int, keys: List[str], limit: int = 0) -> int: + """ + Return the cardinality of the intersect of multiple sets specified by ``keys`. + + When LIMIT provided (defaults to 0 and means unlimited), if the intersection + cardinality reaches limit partway through the computation, the algorithm will + exit and yield limit as the cardinality + + For more information check https://redis.io/commands/sintercard + """ + args = [numkeys, *keys, "LIMIT", limit] + return self.execute_command("SINTERCARD", *args) + def sinterstore(self, dest, keys, *args): """ Store the intersection of sets specified by ``keys`` into a new -- cgit v1.2.1