Skip to content

Commit 7325ccd

Browse files
chayimdvora-h
andcommitted
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 <[email protected]>
1 parent f17b9e8 commit 7325ccd

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

redis/commands/bf/commands.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ def create(self, key, errorRate, capacity, expansion=None, noScale=None):
6969
self.append_no_scale(params, noScale)
7070
return self.execute_command(BF_RESERVE, *params)
7171

72+
reserve = create
73+
7274
def add(self, key, item):
7375
"""
7476
Add to a Bloom Filter `key` an `item`.
@@ -178,6 +180,8 @@ def create(
178180
self.append_max_iterations(params, max_iterations)
179181
return self.execute_command(CF_RESERVE, *params)
180182

183+
reserve = create
184+
181185
def add(self, key, item):
182186
"""
183187
Add an `item` to a Cuckoo Filter `key`.

tests/test_bloom.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ def test_create(client):
3838
assert client.topk().reserve("topk", 5, 100, 5, 0.9)
3939

4040

41+
@pytest.mark.redismod
42+
def test_bf_reserve(client):
43+
"""Testing BF.RESERVE"""
44+
assert client.bf().reserve("bloom", 0.01, 1000)
45+
assert client.bf().reserve("bloom_e", 0.01, 1000, expansion=1)
46+
assert client.bf().reserve("bloom_ns", 0.01, 1000, noScale=True)
47+
assert client.cf().reserve("cuckoo", 1000)
48+
assert client.cf().reserve("cuckoo_e", 1000, expansion=1)
49+
assert client.cf().reserve("cuckoo_bs", 1000, bucket_size=4)
50+
assert client.cf().reserve("cuckoo_mi", 1000, max_iterations=10)
51+
assert client.cms().initbydim("cmsDim", 100, 5)
52+
assert client.cms().initbyprob("cmsProb", 0.01, 0.01)
53+
assert client.topk().reserve("topk", 5, 100, 5, 0.9)
54+
55+
4156
@pytest.mark.redismod
4257
@pytest.mark.experimental
4358
def test_tdigest_create(client):

0 commit comments

Comments
 (0)