RedisBloom / redisbloom-py

Python client for Redisbloom
https://redisbloom.io
BSD 3-Clause "New" or "Revised" License
76 stars 11 forks source link

How to use bfInfo from redisbloom-py #37

Closed scipe closed 3 years ago

scipe commented 3 years ago

Hello folks. There is a bfInfo function inside Client class from redisbloom. But whenever I try to use that command I got results like <redisbloom.client.BFInfo object at 0x7ff5e00d3290>. Can you give me example please how can I print the entire information from real BF INFO command here using that function?

AvitalFineRedis commented 3 years ago

Hi @scipe, BFInfo is an object that has the following properties: capacity, size, filterNum, insertedNum and expansionRate.

You can print them one by one:

info = rb.bfInfo('bloom')
print("capacity = %s" % info.capacity)
print("expansionRate = %s" % info.expansionRate)
print("filterNum = %s" % info.filterNum)
print("insertedNum = %s" % info.insertedNum)
print("size = %s" % info.size)

Or use:

info = rb.bfInfo('bloom')
for attr in dir(info):
    print("info.%s = %r" % (attr, getattr(info, attr)))