RedisBloom Python Client
Project description
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
# Using Bloom Filter
from redisbloom.client import Client
rb = Client()
rb.bfCreate('bloom', 0.01, 1000)
rb.bfAdd('bloom', 'foo') # returns 1
rb.bfAdd('bloom', 'foo') # returns 0
rb.bfExists('bloom', 'foo') # returns 1
rb.bfExists('bloom', 'noexist') # returns 0
# Using Cuckoo Filter
from redisbloom.client import Client
rb = Client()
rb.cfCreate('cuckoo', 1000)
rb.cfAdd('cuckoo', 'filter') # returns 1
rb.cfAddNX('cuckoo', 'filter') # returns 0
rb.cfExists('cuckoo', 'filter') # returns 1
rb.cfExists('cuckoo', 'noexist') # returns 0
# Using Count-Min Sketch
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') # returns [10, 15]
# Using Top-K
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') # returns [1, 1, 0, 1]
rb.topkCount('topk', 'A', 'B', 'C', 'D') # returns [4, 3, 2, 3]
rb.topkList('topk') # returns ['A', 'B', 'E']
rb.topkListWithCount('topk') # returns ['A', 4, 'B', 3, 'E', 3]
API
For complete documentation about RedisBloom's commands, refer to RedisBloom's website.
License
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
redisbloom-py-0.4.1.tar.gz
(9.5 kB
view details)
Built Distribution
File details
Details for the file redisbloom-py-0.4.1.tar.gz
.
File metadata
- Download URL: redisbloom-py-0.4.1.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.7.12 Linux/5.11.0-1020-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38dbbe949e767116a34d556b1e3a6d10800cdcc087a0fba1eb77d4c793966e74 |
|
MD5 | 2ff2504b0ee605044f8621f1b689a7f3 |
|
BLAKE2b-256 | 1199c3bfe9afdc15382feb2e2e6cc38d5dff77167153767ef17b9a442c5df5cf |
File details
Details for the file redisbloom_py-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: redisbloom_py-0.4.1-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.7.12 Linux/5.11.0-1020-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab84f568a39ea6ee116db193e93b800bbecaf00501d7648e8c70466d72f2b938 |
|
MD5 | 579905c81de0cfff3428a35f9076a49f |
|
BLAKE2b-256 | c214b1e850bfc08a53b14c58e1f9026c1456ebc63f7923485e08d42dcb8211b8 |