Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/x0rror/go-bloomfilter
go-bloomfilter is implemented by Golang which supports in-memory and Redis. Moreover, it’s available for a duration-based rotation.
https://github.com/x0rror/go-bloomfilter
bitset bloom bloomfilter filter go golang redis rotation
Last synced: 2 months ago
JSON representation
go-bloomfilter is implemented by Golang which supports in-memory and Redis. Moreover, it’s available for a duration-based rotation.
- Host: GitHub
- URL: https://github.com/x0rror/go-bloomfilter
- Owner: x0rror
- License: bsd-2-clause
- Created: 2022-08-17T09:59:06.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-16T07:34:31.000Z (almost 2 years ago)
- Last Synced: 2024-08-28T20:14:36.589Z (2 months ago)
- Topics: bitset, bloom, bloomfilter, filter, go, golang, redis, rotation
- Language: Go
- Homepage:
- Size: 43 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-golang-repositories - go-bloomfilter - bloomfilter is implemented by Golang which supports in-memory and Redis. Moreover, it�ス鈺 available for a duration-based rotation. (Repositories)
README
# go-bloomfilter
![build workflow](https://github.com/x0rworld/go-bloomfilter/actions/workflows/go.yml/badge.svg)
[![Go Reference](https://pkg.go.dev/badge/github.com/x0rworld/go-bloomfilter.svg)](https://pkg.go.dev/github.com/x0rworld/go-bloomfilter)[go-bloomfilter] is implemented by Golang which supports in-memory and Redis. Moreover, it’s available for a
duration-based rotation.## Resources
- [Documentation]
- [Examples]## Features
- [Supporting bitmap]: in-memory and Redis
- [Rotation]## Installation
```shell
go get github.com/x0rworld/go-bloomfilter
```## Quickstart
```go
package mainimport (
"context"
"github.com/bits-and-blooms/bloom/v3"
"github.com/x0rworld/go-bloomfilter/config"
"github.com/x0rworld/go-bloomfilter/factory"
"log"
)func main() {
m, k := bloom.EstimateParameters(100, 0.01)
// configure factory config
cfg := config.NewDefaultFactoryConfig()
// modify config
cfg.FilterConfig.M = uint64(m)
cfg.FilterConfig.K = uint64(k)
// create factory by config
ff, err := factory.NewFilterFactory(cfg)
if err != nil {
log.Println(err)
return
}
// create filter by factory
f, err := ff.NewFilter(context.Background())
if err != nil {
log.Println(err)
return
}
// manipulate filter: Exist & Add
data := "hello world"
exist, err := f.Exist(data)
if err != nil {
log.Println(err)
return
}
// data: hello world, exist: false
log.Printf("data: %v, exist: %v\n", data, exist)
err = f.Add(data)
if err != nil {
log.Println(err)
return
}
// add data: hello world
log.Printf("add data: %s\n", data)
exist, err = f.Exist(data)
if err != nil {
log.Println(err)
return
}
// data: hello world, exist: true
log.Printf("data: %v, exist: %v\n", data, exist)
}
```More examples such as rotation could be found in [Examples].
[go-bloomfilter]: https://github.com/x0rworld/go-bloomfilter
[Examples]: ./example
[Documentation]: https://pkg.go.dev/github.com/x0rworld/go-bloomfilter
[Supporting bitmap]: ./bitmap
[Rotation]: ./filter/rotator