bloom.go 428 B

123456789101112131415161718
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/tal-tech/go-zero/core/bloom"
  5. "github.com/tal-tech/go-zero/core/stores/redis"
  6. )
  7. func main() {
  8. store := redis.NewRedis("localhost:6379", "node")
  9. filter := bloom.New(store, "testbloom", 64)
  10. filter.Add([]byte("kevin"))
  11. filter.Add([]byte("wan"))
  12. fmt.Println(filter.Exists([]byte("kevin")))
  13. fmt.Println(filter.Exists([]byte("wan")))
  14. fmt.Println(filter.Exists([]byte("nothing")))
  15. }