Skip to content
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![GitHub issues](https://img.shields.io/github/release/RedisBloom/redisbloom-py.svg)](https://github.com/RedisBloom/redisbloom-py/releases/latest)
[![Codecov](https://codecov.io/gh/RedisBloom/redisbloom-py/branch/master/graph/badge.svg)](https://codecov.io/gh/RedisBloom/redisbloom-py)
[![Known Vulnerabilities](https://snyk.io/test/github/RedisBloom/redisbloom-py/badge.svg?targetFile=requirements.txt)](https://snyk.io/test/github/RedisBloom/redisbloom-py?targetFile=requirements.txt)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/RedisBloom/redisbloom-py.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/RedisBloom/redisbloom-py/alerts/)

# Python client for RedisBloom
[![Forum](https://img.shields.io/badge/Forum-RedisBloom-blue)](https://forum.redislabs.com/c/modules/redisbloom)
Expand Down
12 changes: 10 additions & 2 deletions redisbloom/client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import six
from redis.client import Redis, Pipeline
from redis._compat import nativestr
from redis.exceptions import DataError

def bool_ok(response):
return nativestr(response) == 'OK'
Expand Down Expand Up @@ -568,4 +567,13 @@ def pipeline(self, transaction=True, shard_hint=None):
return p

class Pipeline(Pipeline, Client):
"Pipeline for RedisBloom Client"
"Pipeline for RedisBloom Client"
def __init__(self, connection_pool, response_callbacks, transaction, shard_hint):
self.connection_pool = connection_pool
self.connection = None
self.response_callbacks = response_callbacks
self.transaction = transaction
self.shard_hint = shard_hint

self.watching = False
self.reset()
1 change: 0 additions & 1 deletion rltest_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from RLTest import Env
from redisbloom.client import Client as RedisBloom
from redis import ResponseError

'''
from time import sleep
Expand Down
23 changes: 19 additions & 4 deletions test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from time import sleep
from unittest import TestCase
from redisbloom.client import Client as RedisBloom
from redis import ResponseError

xrange = range
rb = None
Expand Down Expand Up @@ -105,6 +104,24 @@ def do_verify():
rb.execute_command('del', 'myBloom')
rb.bfCreate('myBloom', '0.0001', '10000000')

def testBFInfo(self):
expansion = 4
# Store a filter
rb.bfCreate('nonscaling', '0.0001', '1000', noScale=True)
info = rb.bfInfo('nonscaling')
self.assertEqual(info.expansionRate, None)

rb.bfCreate('expanding', '0.0001', '1000', expansion=expansion)
info = rb.bfInfo('expanding')
self.assertEqual(info.expansionRate, 4)

try:
# noScale mean no expansion
rb.bfCreate('myBloom', '0.0001', '1000', expansion=expansion, noScale=True)
self.assertTrue(False)
except:
self.assertTrue(True)

################### Test Cuckoo Filter ###################
def testCFAddInsert(self):
self.assertTrue(rb.cfCreate('cuckoo', 1000))
Expand All @@ -119,7 +136,6 @@ def testCFAddInsert(self):
self.assertEqual([0], rb.cfInsertNX('captest', ['bar'], capacity=1000))
self.assertEqual([1], rb.cfInsert('empty1', ['foo'], capacity=1000))
self.assertEqual([1], rb.cfInsertNX('empty2', ['bar'], capacity=1000))
self.assertRaises(ResponseError, run_func(rb.cfInsert, 'noexist', ['foo']))
info = rb.cfInfo('captest')
self.assertEqual(5, info.insertedNum)
self.assertEqual(0, info.deletedNum)
Expand Down Expand Up @@ -203,7 +219,6 @@ def test_pipeline(self):

for i in range(100):
self.assertTrue(rb.bfExists('pipeline', i))


if __name__ == '__main__':
unittest.main()
unittest.main()