Skip to content

Commit ff062db

Browse files
authored
Merge branch 'master' into search-support
2 parents e3d522f + 8b15101 commit ff062db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1276
-704
lines changed

.github/wordlist.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ ACLs
22
autoload
33
autoloader
44
autoloading
5+
analytics
56
Autoloading
67
backend
78
backends
@@ -13,6 +14,7 @@ customizable
1314
Customizable
1415
dataset
1516
de
17+
DisableIdentity
1618
ElastiCache
1719
extensibility
1820
FPM
@@ -43,6 +45,7 @@ RocksDB
4345
runtime
4446
SHA
4547
sharding
48+
SETNAME
4649
SSL
4750
struct
4851
stunnel

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
steps:
2424
- uses: actions/checkout@v4
2525
- name: golangci-lint
26-
uses: golangci/golangci-lint-action@v3
26+
uses: golangci/golangci-lint-action@v4

.github/workflows/release-drafter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
# Drafts your next Release notes as Pull Requests are merged into "master"
19-
- uses: release-drafter/release-drafter@v5
19+
- uses: release-drafter/release-drafter@v6
2020
with:
2121
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
2222
config-name: release-drafter-config.yml

.github/workflows/spellcheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- name: Checkout
99
uses: actions/checkout@v4
1010
- name: Check Spelling
11-
uses: rojopolis/spellcheck-github-actions@0.35.0
11+
uses: rojopolis/spellcheck-github-actions@0.36.0
1212
with:
1313
config_path: .github/spellcheck-settings.yml
1414
task_name: Markdown
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: RE Tests
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build:
13+
name: build
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
go-version: [1.21.x]
19+
re-build: ["7.4.2-54"]
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Clone Redis EE docker repository
26+
uses: actions/checkout@v4
27+
with:
28+
repository: RedisLabs/redis-ee-docker
29+
path: redis-ee
30+
31+
- name: Set up ${{ matrix.go-version }}
32+
uses: actions/setup-go@v5
33+
with:
34+
go-version: ${{ matrix.go-version }}
35+
36+
- name: Build cluster
37+
working-directory: redis-ee
38+
env:
39+
IMAGE: "redislabs/redis:${{ matrix.re-build }}"
40+
RE_USERNAME: [email protected]
41+
RE_PASS: 12345
42+
RE_CLUSTER_NAME: re-test
43+
RE_USE_OSS_CLUSTER: false
44+
RE_DB_PORT: 6379
45+
run: ./build.sh
46+
47+
- name: Test
48+
env:
49+
RE_CLUSTER: "1"
50+
run: |
51+
go test \
52+
--ginkgo.skip-file="ring_test.go" \
53+
--ginkgo.skip-file="sentinel_test.go" \
54+
--ginkgo.skip-file="osscluster_test.go" \
55+
--ginkgo.skip-file="pubsub_test.go" \
56+
--ginkgo.skip-file="gears_commands_test.go" \
57+
--ginkgo.label-filter='!NonRedisEnterprise'

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)
22

33
test: testdeps
4+
$(eval GO_VERSION := $(shell go version | cut -d " " -f 3 | cut -d. -f2))
45
set -e; for dir in $(GO_MOD_DIRS); do \
6+
if echo "$${dir}" | grep -q "./example" && [ "$(GO_VERSION)" = "19" ]; then \
7+
echo "Skipping go test in $${dir} due to Go version 1.19 and dir contains ./example"; \
8+
continue; \
9+
fi; \
510
echo "go test in $${dir}"; \
611
(cd "$${dir}" && \
712
go mod tidy -compat=1.18 && \

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ key value NoSQL database that uses RocksDB as storage engine and is compatible w
5151

5252
## Features
5353

54-
- Redis 3 commands except QUIT, MONITOR, and SYNC.
55-
- Automatic connection pooling with
54+
- Redis commands except QUIT and SYNC.
55+
- Automatic connection pooling.
5656
- [Pub/Sub](https://redis.uptrace.dev/guide/go-redis-pubsub.html).
5757
- [Pipelines and transactions](https://redis.uptrace.dev/guide/go-redis-pipelines.html).
5858
- [Scripting](https://redis.uptrace.dev/guide/lua-scripting.html).
@@ -161,6 +161,30 @@ func ExampleClient() *redis.Client {
161161

162162
```
163163

164+
165+
### Advanced Configuration
166+
167+
go-redis supports extending the client identification phase to allow projects to send their own custom client identification.
168+
169+
#### Default Client Identification
170+
171+
By default, go-redis automatically sends the client library name and version during the connection process. This feature is available in redis-server as of version 7.2. As a result, the command is "fire and forget", meaning it should fail silently, in the case that the redis server does not support this feature.
172+
173+
#### Disabling Identity Verification
174+
175+
When connection identity verification is not required or needs to be explicitly disabled, a `DisableIndentity` configuration option exists. In V10 of this library, `DisableIndentity` will become `DisableIdentity` in order to fix the associated typo.
176+
177+
To disable verification, set the `DisableIndentity` option to `true` in the Redis client options:
178+
179+
```go
180+
rdb := redis.NewClient(&redis.Options{
181+
Addr: "localhost:6379",
182+
Password: "",
183+
DB: 0,
184+
DisableIndentity: true, // Disable set-info on connect
185+
})
186+
```
187+
164188
## Contributing
165189

166190
Please see [out contributing guidelines](CONTRIBUTING.md) to help us improve this library!

bitmap_commands.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package redis
22

33
import (
44
"context"
5+
"errors"
56
)
67

78
type BitMapCmdable interface {
@@ -37,15 +38,28 @@ func (c cmdable) SetBit(ctx context.Context, key string, offset int64, value int
3738

3839
type BitCount struct {
3940
Start, End int64
41+
Unit string // BYTE(default) | BIT
4042
}
4143

44+
const BitCountIndexByte string = "BYTE"
45+
const BitCountIndexBit string = "BIT"
46+
4247
func (c cmdable) BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd {
4348
args := []interface{}{"bitcount", key}
4449
if bitCount != nil {
50+
if bitCount.Unit == "" {
51+
bitCount.Unit = "BYTE"
52+
}
53+
if bitCount.Unit != BitCountIndexByte && bitCount.Unit != BitCountIndexBit {
54+
cmd := NewIntCmd(ctx)
55+
cmd.SetErr(errors.New("redis: invalid bitcount index"))
56+
return cmd
57+
}
4558
args = append(
4659
args,
4760
bitCount.Start,
4861
bitCount.End,
62+
string(bitCount.Unit),
4963
)
5064
}
5165
cmd := NewIntCmd(ctx, args...)

bitmap_commands_test.go

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package redis_test
2+
3+
import (
4+
. "github.com/bsm/ginkgo/v2"
5+
. "github.com/bsm/gomega"
6+
"github.com/redis/go-redis/v9"
7+
)
8+
9+
type bitCountExpected struct {
10+
Start int64
11+
End int64
12+
Expected int64
13+
}
14+
15+
var _ = Describe("BitCountBite", func() {
16+
var client *redis.Client
17+
key := "bit_count_test"
18+
19+
BeforeEach(func() {
20+
client = redis.NewClient(redisOptions())
21+
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
22+
values := []int{0, 1, 0, 0, 1, 0, 1, 0, 1, 1}
23+
for i, v := range values {
24+
cmd := client.SetBit(ctx, key, int64(i), v)
25+
Expect(cmd.Err()).NotTo(HaveOccurred())
26+
}
27+
})
28+
29+
AfterEach(func() {
30+
Expect(client.Close()).NotTo(HaveOccurred())
31+
})
32+
33+
It("bit count bite", func() {
34+
var expected = []bitCountExpected{
35+
{0, 0, 0},
36+
{0, 1, 1},
37+
{0, 2, 1},
38+
{0, 3, 1},
39+
{0, 4, 2},
40+
{0, 5, 2},
41+
{0, 6, 3},
42+
{0, 7, 3},
43+
{0, 8, 4},
44+
{0, 9, 5},
45+
}
46+
47+
for _, e := range expected {
48+
cmd := client.BitCount(ctx, key, &redis.BitCount{Start: e.Start, End: e.End, Unit: redis.BitCountIndexBit})
49+
Expect(cmd.Err()).NotTo(HaveOccurred())
50+
Expect(cmd.Val()).To(Equal(e.Expected))
51+
}
52+
})
53+
})
54+
55+
var _ = Describe("BitCountByte", func() {
56+
var client *redis.Client
57+
key := "bit_count_test"
58+
59+
BeforeEach(func() {
60+
client = redis.NewClient(redisOptions())
61+
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
62+
values := []int{0, 0, 0, 0, 0, 0, 0, 1, 1, 1}
63+
for i, v := range values {
64+
cmd := client.SetBit(ctx, key, int64(i), v)
65+
Expect(cmd.Err()).NotTo(HaveOccurred())
66+
}
67+
})
68+
69+
AfterEach(func() {
70+
Expect(client.Close()).NotTo(HaveOccurred())
71+
})
72+
73+
It("bit count byte", func() {
74+
var expected = []bitCountExpected{
75+
{0, 0, 1},
76+
{0, 1, 3},
77+
}
78+
79+
for _, e := range expected {
80+
cmd := client.BitCount(ctx, key, &redis.BitCount{Start: e.Start, End: e.End, Unit: redis.BitCountIndexByte})
81+
Expect(cmd.Err()).NotTo(HaveOccurred())
82+
Expect(cmd.Val()).To(Equal(e.Expected))
83+
}
84+
})
85+
86+
It("bit count byte with no unit specified", func() {
87+
var expected = []bitCountExpected{
88+
{0, 0, 1},
89+
{0, 1, 3},
90+
}
91+
92+
for _, e := range expected {
93+
cmd := client.BitCount(ctx, key, &redis.BitCount{Start: e.Start, End: e.End})
94+
Expect(cmd.Err()).NotTo(HaveOccurred())
95+
Expect(cmd.Val()).To(Equal(e.Expected))
96+
}
97+
})
98+
})

0 commit comments

Comments
 (0)