Skip to content

Commit 25ccce0

Browse files
authored
BF.CARD support (#49)
1 parent c298774 commit 25ccce0

File tree

6 files changed

+30
-54
lines changed

6 files changed

+30
-54
lines changed

.circleci/config.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/integration.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ on:
1010
- master
1111
- main
1212
- '[0-9].[0-9]'
13-
pull_request:
14-
branches:
15-
- master
16-
- main
17-
- '[0-9].[0-9]'
18-
schedule:
19-
- cron: '0 1 * * *'
13+
pull_request:
14+
branches:
15+
- master
16+
- main
17+
- '[0-9].[0-9]'
18+
schedule:
19+
- cron: '0 1 * * *'
2020

2121
jobs:
2222

@@ -27,20 +27,16 @@ jobs:
2727
- uses: actions/checkout@v3
2828
- run: |
2929
make checkfmt
30-
make lint
3130
3231
integration:
33-
services:
34-
image: redislabs/rebloom:edge
35-
port:
36-
- 6379:6379
3732
name: Build and test
3833
runs-on: ubuntu-latest
3934
steps:
4035
- uses: actions/setup-go@v3
4136
with:
4237
go-version: 1.18.x
4338
- uses: actions/checkout@v3
39+
- run: docker run -p 6379:6379 -d redis/redis-stack-server:edge
4440
- run: |
4541
make get
4642
make coverage

Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ checkfmt:
2020
fi && \
2121
exit $$EXIT_CODE
2222

23-
lint:
24-
$(GOGET) github.com/golangci/golangci-lint/cmd/golangci-lint
25-
golangci-lint run
26-
2723
fmt:
2824
$(GOFMT) ./...
2925

@@ -36,4 +32,3 @@ test: get
3632

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

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[![license](https://img.shields.io/github/license/RedisBloom/redisbloom-go.svg)](https://github.com/RedisBloom/redisbloom-go)
2-
[![CircleCI](https://circleci.com/gh/RedisBloom/redisbloom-go.svg?style=svg)](https://circleci.com/gh/RedisBloom/redisbloom-go)
32
[![GitHub issues](https://img.shields.io/github/release/RedisBloom/redisbloom-go.svg)](https://github.com/RedisBloom/redisbloom-go/releases/latest)
43
[![Codecov](https://codecov.io/gh/RedisBloom/redisbloom-go/branch/master/graph/badge.svg)](https://codecov.io/gh/RedisBloom/redisbloom-go)
54
[![GoDoc](https://godoc.org/github.com/RedisBloom/redisbloom-go?status.svg)](https://pkg.go.dev/github.com/RedisBloom/redisbloom-go)

client.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ func (client *Client) BfAddMulti(key string, items []string) ([]int64, error) {
169169
return redis.Int64s(result, err)
170170
}
171171

172+
func (client *Client) BfCard(key string) (int64, error) {
173+
conn := client.Pool.Get()
174+
defer conn.Close()
175+
args := redis.Args{key}
176+
result, err := conn.Do("BF.CARD", args...)
177+
return redis.Int64(result, err)
178+
}
179+
172180
// BfExistsMulti - Determines if one or more items may exist in the filter or not.
173181
// args:
174182
// key - the name of the filter

client_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,20 @@ func TestClient_BfAddMulti(t *testing.T) {
116116
assert.NotNil(t, ret)
117117
}
118118

119+
func TestClient_BfCard(t *testing.T) {
120+
keyname := "bfcardkey"
121+
client.FlushAll()
122+
res, err := client.BfCard(keyname)
123+
assert.Nil(t, err)
124+
assert.Equal(t, res, int64(0))
125+
126+
client.FlushAll()
127+
client.BfAddMulti(keyname, []string{"a", "b", "c"})
128+
res, err = client.BfCard(keyname)
129+
assert.Nil(t, err)
130+
assert.Equal(t, res, int64(3))
131+
}
132+
119133
func TestClient_BfExistsMulti(t *testing.T) {
120134
client.FlushAll()
121135
key := "test_exists_multi"

0 commit comments

Comments
 (0)