Python client for RedisBloom
redisbloom-py is a package that gives developers easy access to several probabilistic data structures. The package extends redis-py's interface with RedisBloom's API.
Installation
$ pip install redisbloom
Usage example
from redisbloom.client import Client
rb = Client()
rb.bfCreate('bloom', 0.01, 1000)
rb.bfAdd('bloom', 'foo')
rb.bfAdd('bloom', 'foo')
rb.bfExists('bloom', 'foo')
rb.bfExists('bloom', 'noexist')
from redisbloom.client import Client
rb = Client()
rb.cfCreate('cuckoo', 1000)
rb.cfAdd('cuckoo', 'filter')
rb.cfAddNX('cuckoo', 'filter')
rb.cfExists('cuckoo', 'filter')
rb.cfExists('cuckoo', 'noexist')
from redisbloom.client import Client
rb = Client()
rb.cmsInitByDim('dim', 1000, 5)
rb.cmsIncrBy('dim', ['foo'], [5])
rb.cmsIncrBy('dim', ['foo', 'bar'], [5, 15])
rb.cmsQuery('dim', 'foo', 'bar')
from redisbloom.client import Client
rb = Client()
rb.topkReserve('topk', 3, 20, 3, 0.9)
rb.topkAdd('topk', 'A', 'B', 'C', 'D', 'E', 'A', 'A', 'B',
'C', 'G', 'D', 'B', 'D', 'A', 'E', 'E')
rb.topkQuery('topk', 'A', 'B', 'C', 'D')
rb.topkCount('topk', 'A', 'B', 'C', 'D')
rb.topkList('topk')
rb.topkListWithCount('topk')
API
For complete documentation about RedisBloom's commands, refer to RedisBloom's website.
License
BSD 3-Clause
Development
- Create a virtualenv to manage your python dependencies, and ensure it's active.
virtualenv -v venv
- Install pypoetry to manage your dependencies.
pip install poetry
- Install dependencies.
poetry install
tox runs all tests as its default target. Running tox by itself will run unit tests. Ensure you have a running redis, with the module loaded.