summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChayim <chayim@users.noreply.github.com>2022-08-30 02:38:02 +0300
committerGitHub <noreply@github.com>2022-08-30 02:38:02 +0300
commita6d473b9e5f09902426042057b0dff9e420d9b98 (patch)
tree271cef8641a95016242b932067dd55c22395ea51
parentbd0e8f26d8af5722a8b040bed6a75831bade81df (diff)
downloadredis-py-a6d473b9e5f09902426042057b0dff9e420d9b98.tar.gz
Adding reserve as an alias for create, so that we have BF.RESERVE and CF.RESERVE accuratenly supported (#2331)
* Adding reserve as an alias for create, so that we have BF.RESERVE accuratenly supported * add reserve to cf commands Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
-rw-r--r--redis/commands/bf/commands.py4
-rw-r--r--tests/test_bloom.py15
2 files changed, 19 insertions, 0 deletions
diff --git a/redis/commands/bf/commands.py b/redis/commands/bf/commands.py
index 2b16139..9c3c97c 100644
--- a/redis/commands/bf/commands.py
+++ b/redis/commands/bf/commands.py
@@ -69,6 +69,8 @@ class BFCommands:
self.append_no_scale(params, noScale)
return self.execute_command(BF_RESERVE, *params)
+ reserve = create
+
def add(self, key, item):
"""
Add to a Bloom Filter `key` an `item`.
@@ -178,6 +180,8 @@ class CFCommands:
self.append_max_iterations(params, max_iterations)
return self.execute_command(CF_RESERVE, *params)
+ reserve = create
+
def add(self, key, item):
"""
Add an `item` to a Cuckoo Filter `key`.
diff --git a/tests/test_bloom.py b/tests/test_bloom.py
index 9a3e4a4..2ff2ea7 100644
--- a/tests/test_bloom.py
+++ b/tests/test_bloom.py
@@ -39,6 +39,21 @@ def test_create(client):
@pytest.mark.redismod
+def test_bf_reserve(client):
+ """Testing BF.RESERVE"""
+ assert client.bf().reserve("bloom", 0.01, 1000)
+ assert client.bf().reserve("bloom_e", 0.01, 1000, expansion=1)
+ assert client.bf().reserve("bloom_ns", 0.01, 1000, noScale=True)
+ assert client.cf().reserve("cuckoo", 1000)
+ assert client.cf().reserve("cuckoo_e", 1000, expansion=1)
+ assert client.cf().reserve("cuckoo_bs", 1000, bucket_size=4)
+ assert client.cf().reserve("cuckoo_mi", 1000, max_iterations=10)
+ assert client.cms().initbydim("cmsDim", 100, 5)
+ assert client.cms().initbyprob("cmsProb", 0.01, 0.01)
+ assert client.topk().reserve("topk", 5, 100, 5, 0.9)
+
+
+@pytest.mark.redismod
@pytest.mark.experimental
def test_tdigest_create(client):
assert client.tdigest().create("tDigest", 100)