go-zero/example/bloom/bloom.go

19 lines
428 B
Go
Raw Normal View History

2020-07-26 17:09:05 +08:00
package main
import (
"fmt"
2020-08-08 16:40:10 +08:00
"github.com/tal-tech/go-zero/core/bloom"
"github.com/tal-tech/go-zero/core/stores/redis"
2020-07-26 17:09:05 +08:00
)
func main() {
store := redis.NewRedis("localhost:6379", "node")
filter := bloom.New(store, "testbloom", 64)
filter.Add([]byte("kevin"))
filter.Add([]byte("wan"))
fmt.Println(filter.Exists([]byte("kevin")))
fmt.Println(filter.Exists([]byte("wan")))
fmt.Println(filter.Exists([]byte("nothing")))
}