redis / redis-py

Redis Python client
MIT License
12.62k stars 2.52k forks source link

Full example in redis module docs #2014

Closed kylekyle closed 2 years ago

kylekyle commented 2 years ago

Version: redis-py 4.1.4

Platform: Python 3.9.7 on Debian 11 (bullseye)

Description: According to the docs, the following snippet of code should work for accessing the RedisBloom commands on a client:

import redis
filter = redis.bf().create("bloom", 0.01, 1000)
filter.add("bloom", "foo")

But running this gives:

AttributeError: module 'redis' has no attribute 'bf'

Same result for the other RedisBloom commands (cms/topk/etc.)

kylekyle commented 2 years ago

Bah. I didn't realize the redis referred to in line 2 was the client not the module. It should be:

import redis
client = redis.Redis(host='localhost')
filter = client.bf().create("bloom", 0.01, 1000)
filter.add("bloom", "foo")