linvon / cuckoo-filter

Cuckoo Filter go implement, better than Bloom Filter, configurable and space optimized 布谷鸟过滤器的Go实现,优于布隆过滤器,可以定制化过滤器参数,并进行了空间优化
MIT License
294 stars 27 forks source link

How can I persistence the filter with redis ? #4

Closed woorui closed 2 years ago

woorui commented 2 years ago

I want persistence the cuckoo-filter for my distributed service, I would like to use redis.

Can you give me any suggestion on my issue ?

thanks.

linvon commented 2 years ago
cf := cuckoo.NewFilter(4, 9, 3900, cuckoo.TableTypePacked)
b := cf.Encode()
redis.Set(your_key, b)

data := redis.Get(your_key)
newCf, _ := cuckoo.Decode(data)

Encode() return []byte slice represent your filter, you can save it on Redis. Then you can get []byte data from Redis and use Decode(data) to rebuild your filter

woorui commented 2 years ago

https://github.com/woorui/cuckoo-filter-redis

Is this Wrapping ok ?

linvon commented 2 years ago

https://github.com/woorui/cuckoo-filter-redis

Is this Wrapping ok ?

Looks ok

woorui commented 2 years ago

ok, many thanks