Skip to content
Python client for Redisbloom
Branch: master
Clone or download
Latest commit de7f1bf Jun 24, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci bloom client + tests (#1) Jun 12, 2019
redisbloom Update for TopK.Add which returns expelled items (#3) Jun 24, 2019
.gitignore bloom client + tests (#1) Jun 12, 2019
LICENSE Create LICENSE Jun 11, 2019
README.md
requirements.txt bloom client + tests (#1) Jun 12, 2019
rltest_commands.py bloom client + tests (#1) Jun 12, 2019
setup.cfg bloom client + tests (#1) Jun 12, 2019
setup.py update to version 0.2.0 Jun 24, 2019
test_commands.py Update for TopK.Add which returns expelled items (#3) Jun 24, 2019

README.md

Python client for RedisBloom

license PyPI version CircleCI GitHub issues Codecov

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 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 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 Cuckoo Filter
from redisbloom 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 Cuckoo Filter
from redisbloom 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 ['D', 'A', 'B']

API

For complete documentation about RedisBloom's commands, refer to RedisBloom's website.

License

BSD 3-Clause

You can’t perform that action at this time.