Skip to content

Commit

Permalink
Merge pull request #493 from proost/feat-rueidisprob
Browse files Browse the repository at this point in the history
feat: rueidisprob package and standard bloom filter
  • Loading branch information
rueian committed Mar 16, 2024
2 parents f99b48e + cfcfad5 commit 236216b
Show file tree
Hide file tree
Showing 9 changed files with 1,659 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ jobs:
for n in {1..5}; do ../dockertest.sh $list && break; done
no_output_timeout: 15m

- run: # test ./rueidisprob/go.mod
command: |
cd $CIRCLE_WORKING_DIRECTORY/rueidisprob
list=$(go list ./... | circleci tests split --split-by=timings)
echo "Test Packages: $list"
for n in {1..5}; do ../dockertest.sh $list && break; done
no_output_timeout: 15m

- store_test_results:
path: .
- run: curl -Os https://uploader.codecov.io/latest/linux/codecov && chmod +x codecov && ./codecov -t ${CODECOV_TOKEN}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ A fast Golang Redis client that does auto pipelining and supports server-assiste
* [Go-redis like API adapter](./rueidiscompat) by [@418Coffee](https://github.com/418Coffee)
* Pub/Sub, Sharded Pub/Sub, Streams
* Redis Cluster, Sentinel, RedisJSON, RedisBloom, RediSearch, RedisTimeseries, etc.
* [Probabilistic Data Structures without Redis Stack](./rueidisprob)

---

Expand Down
1 change: 1 addition & 0 deletions dockertest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ set -ev

trap "docker-compose down -v" EXIT
docker-compose up -d
sleep 5
go install gotest.tools/gotestsum@v1.10.0
gotestsum --format standard-verbose --junitfile unit-tests.xml -- -coverprofile=coverage.out -race -timeout 30m "$@"
56 changes: 56 additions & 0 deletions rueidisprob/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# rueidisprob

A Probabilistic Data Structures without Redis Stack.

## Features

### Bloom Filter

It is a space-efficient probabilistic data structure that is used to test whether an element is a member of a set.
False positive matches are possible, but false negatives are not.
In other words, a query returns either "possibly in set" or "definitely not in set".
Elements can be added to the set, but not removed.

Example:

```go
package main

import (
"github.com/redis/rueidis"
"github.com/redis/rueidis/rueidisprob"
)

func main() {
client, err := rueidis.NewClient(rueidis.ClientOption{
InitAddress: []string{"localhost:6379"},
})
if err != nil {
panic(err)
}

bf := rueidisprob.NewBloomFilter(client, "bloom_filter", 1000, 0.01)

err := bf.Add("hello")
if err != nil {
panic(err)
}

err := bf.Add("world")
if err != nil {
panic(err)
}

exists, err := bf.Exists("hello")
if err != nil {
panic(err)
}
fmt.Println(exists) // true

exists, err = bf.Exists("world")
if err != nil {
panic(err)
}
fmt.Println(exists) // true
}
```
Loading

0 comments on commit 236216b

Please sign in to comment.