Skip to content

Commit

Permalink
BF.CARD support (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
chayim authored Mar 30, 2023
1 parent c298774 commit 25ccce0
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 54 deletions.
36 changes: 0 additions & 36 deletions .circleci/config.yml

This file was deleted.

20 changes: 8 additions & 12 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ on:
- master
- main
- '[0-9].[0-9]'
pull_request:
branches:
- master
- main
- '[0-9].[0-9]'
schedule:
- cron: '0 1 * * *'
pull_request:
branches:
- master
- main
- '[0-9].[0-9]'
schedule:
- cron: '0 1 * * *'

jobs:

Expand All @@ -27,20 +27,16 @@ jobs:
- uses: actions/checkout@v3
- run: |
make checkfmt
make lint
integration:
services:
image: redislabs/rebloom:edge
port:
- 6379:6379
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18.x
- uses: actions/checkout@v3
- run: docker run -p 6379:6379 -d redis/redis-stack-server:edge
- run: |
make get
make coverage
Expand Down
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ checkfmt:
fi && \
exit $$EXIT_CODE

lint:
$(GOGET) github.com/golangci/golangci-lint/cmd/golangci-lint
golangci-lint run

fmt:
$(GOFMT) ./...

Expand All @@ -36,4 +32,3 @@ test: get

coverage: get test
$(GOTEST) -race -coverprofile=coverage.txt -covermode=atomic .

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[![license](https://img.shields.io/github/license/RedisBloom/redisbloom-go.svg)](https://github.com/RedisBloom/redisbloom-go)
[![CircleCI](https://circleci.com/gh/RedisBloom/redisbloom-go.svg?style=svg)](https://circleci.com/gh/RedisBloom/redisbloom-go)
[![GitHub issues](https://img.shields.io/github/release/RedisBloom/redisbloom-go.svg)](https://github.com/RedisBloom/redisbloom-go/releases/latest)
[![Codecov](https://codecov.io/gh/RedisBloom/redisbloom-go/branch/master/graph/badge.svg)](https://codecov.io/gh/RedisBloom/redisbloom-go)
[![GoDoc](https://godoc.org/github.com/RedisBloom/redisbloom-go?status.svg)](https://pkg.go.dev/github.com/RedisBloom/redisbloom-go)
Expand Down
8 changes: 8 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ func (client *Client) BfAddMulti(key string, items []string) ([]int64, error) {
return redis.Int64s(result, err)
}

func (client *Client) BfCard(key string) (int64, error) {
conn := client.Pool.Get()
defer conn.Close()
args := redis.Args{key}
result, err := conn.Do("BF.CARD", args...)
return redis.Int64(result, err)
}

// BfExistsMulti - Determines if one or more items may exist in the filter or not.
// args:
// key - the name of the filter
Expand Down
14 changes: 14 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@ func TestClient_BfAddMulti(t *testing.T) {
assert.NotNil(t, ret)
}

func TestClient_BfCard(t *testing.T) {
keyname := "bfcardkey"
client.FlushAll()
res, err := client.BfCard(keyname)
assert.Nil(t, err)
assert.Equal(t, res, int64(0))

client.FlushAll()
client.BfAddMulti(keyname, []string{"a", "b", "c"})
res, err = client.BfCard(keyname)
assert.Nil(t, err)
assert.Equal(t, res, int64(3))
}

func TestClient_BfExistsMulti(t *testing.T) {
client.FlushAll()
key := "test_exists_multi"
Expand Down

0 comments on commit 25ccce0

Please sign in to comment.