Skip to content

Commit 9ef438b

Browse files
committed
Merge remote-tracking branch 'origin/master' into ndyakov/token-based-auth
2 parents 5410adb + 9762559 commit 9ef438b

Some content is hidden

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

42 files changed

+975
-103
lines changed

.github/actions/run-tests/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ runs:
2525
2626
# Mapping of redis version to redis testing containers
2727
declare -A redis_version_mapping=(
28-
["8.0-M03"]="8.0-M04-pre"
28+
["8.0-M05"]="8.0-M05-pre"
2929
["7.4.2"]="rs-7.4.0-v2"
3030
["7.2.7"]="rs-7.2.0-v14"
3131
)

.github/workflows/build.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
redis-version:
21-
- "8.0-M03" # 8.0 milestone 4
21+
- "8.0-M05" # 8.0 milestone 5
2222
- "7.4.2" # should use redis stack 7.4
2323
go-version:
2424
- "1.23.x"
@@ -43,7 +43,7 @@ jobs:
4343
4444
# Mapping of redis version to redis testing containers
4545
declare -A redis_version_mapping=(
46-
["8.0-M03"]="8.0-M04-pre"
46+
["8.0-M05"]="8.0-M05-pre"
4747
["7.4.2"]="rs-7.4.0-v2"
4848
)
4949
if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then
@@ -72,7 +72,7 @@ jobs:
7272
fail-fast: false
7373
matrix:
7474
redis-version:
75-
- "8.0-M03" # 8.0 milestone 4
75+
- "8.0-M05" # 8.0 milestone 5
7676
- "7.4.2" # should use redis stack 7.4
7777
- "7.2.7" # should redis stack 7.2
7878
go-version:

.github/workflows/golangci-lint.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323
- name: golangci-lint
24-
uses: golangci/golangci-lint-action@v6.5.0
24+
uses: golangci/golangci-lint-action@v6.5.2
25+
with:
26+
verify: false # disable verifying the configuration since golangci is currently introducing breaking changes in the configuration
27+

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test.ci:
1717
(cd "$${dir}" && \
1818
go mod tidy -compat=1.18 && \
1919
go vet && \
20-
go test -coverprofile=coverage.txt -covermode=atomic ./... -race); \
20+
go test -v -coverprofile=coverage.txt -covermode=atomic ./... -race); \
2121
done
2222
cd internal/customvet && go build .
2323
go vet -vettool ./internal/customvet/customvet

README.md

+18-10
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@
66
[![codecov](https://codecov.io/github/redis/go-redis/graph/badge.svg?token=tsrCZKuSSw)](https://codecov.io/github/redis/go-redis)
77
[![Chat](https://discordapp.com/api/guilds/752070105847955518/widget.png)](https://discord.gg/rWtp5Aj)
88

9-
> go-redis is brought to you by :star: [**uptrace/uptrace**](https://github.com/uptrace/uptrace).
10-
> Uptrace is an open-source APM tool that supports distributed tracing, metrics, and logs. You can
11-
> use it to monitor applications and set up automatic alerts to receive notifications via email,
12-
> Slack, Telegram, and others.
13-
>
14-
> See [OpenTelemetry](https://github.com/redis/go-redis/tree/master/example/otel) example which
15-
> demonstrates how you can use Uptrace to monitor go-redis.
9+
> go-redis is the official Redis client library for the Go programming language. It offers a straightforward interface for interacting with Redis servers.
1610
1711
## Supported versions
1812

@@ -184,16 +178,18 @@ By default, go-redis automatically sends the client library name and version dur
184178

185179
#### Disabling Identity Verification
186180

187-
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.
181+
When connection identity verification is not required or needs to be explicitly disabled, a `DisableIdentity` configuration option exists.
182+
Initially there was a typo and the option was named `DisableIndentity` instead of `DisableIdentity`. The misspelled option is marked as Deprecated and will be removed in V10 of this library.
183+
Although both options will work at the moment, the correct option is `DisableIdentity`. The deprecated option will be removed in V10 of this library, so please use the correct option name to avoid any issues.
188184

189-
To disable verification, set the `DisableIndentity` option to `true` in the Redis client options:
185+
To disable verification, set the `DisableIdentity` option to `true` in the Redis client options:
190186

191187
```go
192188
rdb := redis.NewClient(&redis.Options{
193189
Addr: "localhost:6379",
194190
Password: "",
195191
DB: 0,
196-
DisableIndentity: true, // Disable set-info on connect
192+
DisableIdentity: true, // Disable set-info on connect
197193
})
198194
```
199195

@@ -215,6 +211,10 @@ res1, err := client.FTSearchWithArgs(ctx, "txt", "foo bar", &redis.FTSearchOptio
215211
val1 := client.FTSearchWithArgs(ctx, "txt", "foo bar", &redis.FTSearchOptions{}).RawVal()
216212
```
217213

214+
#### Redis-Search Default Dialect
215+
216+
In the Redis-Search module, **the default dialect is 2**. If needed, you can explicitly specify a different dialect using the appropriate configuration in your queries.
217+
218218
## Contributing
219219

220220
Please see [out contributing guidelines](CONTRIBUTING.md) to help us improve this library!
@@ -297,6 +297,14 @@ REDIS_PORT=9999 go test <your options>
297297

298298
## Contributors
299299

300+
> The go-redis project was originally initiated by :star: [**uptrace/uptrace**](https://github.com/uptrace/uptrace).
301+
> Uptrace is an open-source APM tool that supports distributed tracing, metrics, and logs. You can
302+
> use it to monitor applications and set up automatic alerts to receive notifications via email,
303+
> Slack, Telegram, and others.
304+
>
305+
> See [OpenTelemetry](https://github.com/redis/go-redis/tree/master/example/otel) example which
306+
> demonstrates how you can use Uptrace to monitor go-redis.
307+
300308
Thanks to all the people who already contributed!
301309

302310
<a href="https://github.com/redis/go-redis/graphs/contributors">

bench_decode_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func NewClientStub(resp []byte) *ClientStub {
3030
Dialer: func(ctx context.Context, network, addr string) (net.Conn, error) {
3131
return stub.stubConn(initHello), nil
3232
},
33-
DisableIndentity: true,
33+
DisableIdentity: true,
3434
})
3535
return stub
3636
}
@@ -46,7 +46,7 @@ func NewClusterClientStub(resp []byte) *ClientStub {
4646
Dialer: func(ctx context.Context, network, addr string) (net.Conn, error) {
4747
return stub.stubConn(initHello), nil
4848
},
49-
DisableIndentity: true,
49+
DisableIdentity: true,
5050

5151
ClusterSlots: func(_ context.Context) ([]ClusterSlot, error) {
5252
return []ClusterSlot{

commands_test.go

+142-1
Original file line numberDiff line numberDiff line change
@@ -2659,7 +2659,6 @@ var _ = Describe("Commands", func() {
26592659
Expect(res).To(Equal([]int64{1, 1, -2}))
26602660
})
26612661

2662-
26632662
It("should HPExpire", Label("hash-expiration", "NonRedisEnterprise"), func() {
26642663
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
26652664
res, err := client.HPExpire(ctx, "no_such_key", 10*time.Second, "field1", "field2", "field3").Result()
@@ -2812,6 +2811,148 @@ var _ = Describe("Commands", func() {
28122811
Expect(err).NotTo(HaveOccurred())
28132812
Expect(res[0]).To(BeNumerically("~", 10*time.Second.Milliseconds(), 1))
28142813
})
2814+
2815+
It("should HGETDEL", Label("hash", "HGETDEL"), func() {
2816+
SkipBeforeRedisVersion(7.9, "requires Redis 8.x")
2817+
2818+
err := client.HSet(ctx, "myhash", "f1", "val1", "f2", "val2", "f3", "val3").Err()
2819+
Expect(err).NotTo(HaveOccurred())
2820+
2821+
// Execute HGETDEL on fields f1 and f2.
2822+
res, err := client.HGetDel(ctx, "myhash", "f1", "f2").Result()
2823+
Expect(err).NotTo(HaveOccurred())
2824+
// Expect the returned values for f1 and f2.
2825+
Expect(res).To(Equal([]string{"val1", "val2"}))
2826+
2827+
// Verify that f1 and f2 have been deleted, while f3 remains.
2828+
remaining, err := client.HMGet(ctx, "myhash", "f1", "f2", "f3").Result()
2829+
Expect(err).NotTo(HaveOccurred())
2830+
Expect(remaining[0]).To(BeNil())
2831+
Expect(remaining[1]).To(BeNil())
2832+
Expect(remaining[2]).To(Equal("val3"))
2833+
})
2834+
2835+
It("should return nil responses for HGETDEL on non-existent key", Label("hash", "HGETDEL"), func() {
2836+
SkipBeforeRedisVersion(7.9, "requires Redis 8.x")
2837+
// HGETDEL on a key that does not exist.
2838+
res, err := client.HGetDel(ctx, "nonexistent", "f1", "f2").Result()
2839+
Expect(err).To(BeNil())
2840+
Expect(res).To(Equal([]string{"", ""}))
2841+
})
2842+
2843+
// -----------------------------
2844+
// HGETEX with various TTL options
2845+
// -----------------------------
2846+
It("should HGETEX with EX option", Label("hash", "HGETEX"), func() {
2847+
SkipBeforeRedisVersion(7.9, "requires Redis 8.x")
2848+
2849+
err := client.HSet(ctx, "myhash", "f1", "val1", "f2", "val2").Err()
2850+
Expect(err).NotTo(HaveOccurred())
2851+
2852+
// Call HGETEX with EX option and 60 seconds TTL.
2853+
opt := redis.HGetEXOptions{
2854+
ExpirationType: redis.HGetEXExpirationEX,
2855+
ExpirationVal: 60,
2856+
}
2857+
res, err := client.HGetEXWithArgs(ctx, "myhash", &opt, "f1", "f2").Result()
2858+
Expect(err).NotTo(HaveOccurred())
2859+
Expect(res).To(Equal([]string{"val1", "val2"}))
2860+
})
2861+
2862+
It("should HGETEX with PERSIST option", Label("hash", "HGETEX"), func() {
2863+
SkipBeforeRedisVersion(7.9, "requires Redis 8.x")
2864+
2865+
err := client.HSet(ctx, "myhash", "f1", "val1", "f2", "val2").Err()
2866+
Expect(err).NotTo(HaveOccurred())
2867+
2868+
// Call HGETEX with PERSIST (no TTL value needed).
2869+
opt := redis.HGetEXOptions{ExpirationType: redis.HGetEXExpirationPERSIST}
2870+
res, err := client.HGetEXWithArgs(ctx, "myhash", &opt, "f1", "f2").Result()
2871+
Expect(err).NotTo(HaveOccurred())
2872+
Expect(res).To(Equal([]string{"val1", "val2"}))
2873+
})
2874+
2875+
It("should HGETEX with EXAT option", Label("hash", "HGETEX"), func() {
2876+
SkipBeforeRedisVersion(7.9, "requires Redis 8.x")
2877+
2878+
err := client.HSet(ctx, "myhash", "f1", "val1", "f2", "val2").Err()
2879+
Expect(err).NotTo(HaveOccurred())
2880+
2881+
// Set expiration at a specific Unix timestamp (60 seconds from now).
2882+
expireAt := time.Now().Add(60 * time.Second).Unix()
2883+
opt := redis.HGetEXOptions{
2884+
ExpirationType: redis.HGetEXExpirationEXAT,
2885+
ExpirationVal: expireAt,
2886+
}
2887+
res, err := client.HGetEXWithArgs(ctx, "myhash", &opt, "f1", "f2").Result()
2888+
Expect(err).NotTo(HaveOccurred())
2889+
Expect(res).To(Equal([]string{"val1", "val2"}))
2890+
})
2891+
2892+
// -----------------------------
2893+
// HSETEX with FNX/FXX options
2894+
// -----------------------------
2895+
It("should HSETEX with FNX condition", Label("hash", "HSETEX"), func() {
2896+
SkipBeforeRedisVersion(7.9, "requires Redis 8.x")
2897+
2898+
opt := redis.HSetEXOptions{
2899+
Condition: redis.HSetEXFNX,
2900+
ExpirationType: redis.HSetEXExpirationEX,
2901+
ExpirationVal: 60,
2902+
}
2903+
res, err := client.HSetEXWithArgs(ctx, "myhash", &opt, "f1", "val1").Result()
2904+
Expect(err).NotTo(HaveOccurred())
2905+
Expect(res).To(Equal(int64(1)))
2906+
2907+
opt = redis.HSetEXOptions{
2908+
Condition: redis.HSetEXFNX,
2909+
ExpirationType: redis.HSetEXExpirationEX,
2910+
ExpirationVal: 60,
2911+
}
2912+
res, err = client.HSetEXWithArgs(ctx, "myhash", &opt, "f1", "val2").Result()
2913+
Expect(err).NotTo(HaveOccurred())
2914+
Expect(res).To(Equal(int64(0)))
2915+
})
2916+
2917+
It("should HSETEX with FXX condition", Label("hash", "HSETEX"), func() {
2918+
SkipBeforeRedisVersion(7.9, "requires Redis 8.x")
2919+
2920+
err := client.HSet(ctx, "myhash", "f2", "val1").Err()
2921+
Expect(err).NotTo(HaveOccurred())
2922+
2923+
opt := redis.HSetEXOptions{
2924+
Condition: redis.HSetEXFXX,
2925+
ExpirationType: redis.HSetEXExpirationEX,
2926+
ExpirationVal: 60,
2927+
}
2928+
res, err := client.HSetEXWithArgs(ctx, "myhash", &opt, "f2", "val2").Result()
2929+
Expect(err).NotTo(HaveOccurred())
2930+
Expect(res).To(Equal(int64(1)))
2931+
opt = redis.HSetEXOptions{
2932+
Condition: redis.HSetEXFXX,
2933+
ExpirationType: redis.HSetEXExpirationEX,
2934+
ExpirationVal: 60,
2935+
}
2936+
res, err = client.HSetEXWithArgs(ctx, "myhash", &opt, "f3", "val3").Result()
2937+
Expect(err).NotTo(HaveOccurred())
2938+
Expect(res).To(Equal(int64(0)))
2939+
})
2940+
2941+
It("should HSETEX with multiple field operations", Label("hash", "HSETEX"), func() {
2942+
SkipBeforeRedisVersion(7.9, "requires Redis 8.x")
2943+
2944+
opt := redis.HSetEXOptions{
2945+
ExpirationType: redis.HSetEXExpirationEX,
2946+
ExpirationVal: 60,
2947+
}
2948+
res, err := client.HSetEXWithArgs(ctx, "myhash", &opt, "f1", "val1", "f2", "val2").Result()
2949+
Expect(err).NotTo(HaveOccurred())
2950+
Expect(res).To(Equal(int64(1)))
2951+
2952+
values, err := client.HMGet(ctx, "myhash", "f1", "f2").Result()
2953+
Expect(err).NotTo(HaveOccurred())
2954+
Expect(values).To(Equal([]interface{}{"val1", "val2"}))
2955+
})
28152956
})
28162957

28172958
Describe("hyperloglog", func() {

docker-compose.yml

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
services:
44
redis:
55
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
6+
platform: linux/amd64
67
container_name: redis-standalone
78
environment:
89
- TLS_ENABLED=yes
@@ -23,6 +24,7 @@ services:
2324

2425
osscluster:
2526
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
27+
platform: linux/amd64
2628
container_name: redis-osscluster
2729
environment:
2830
- NODES=6
@@ -39,6 +41,7 @@ services:
3941

4042
sentinel-cluster:
4143
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
44+
platform: linux/amd64
4245
container_name: redis-sentinel-cluster
4346
network_mode: "host"
4447
environment:
@@ -58,6 +61,7 @@ services:
5861

5962
sentinel:
6063
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
64+
platform: linux/amd64
6165
container_name: redis-sentinel
6266
depends_on:
6367
- sentinel-cluster
@@ -81,6 +85,7 @@ services:
8185

8286
ring-cluster:
8387
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2}
88+
platform: linux/amd64
8489
container_name: redis-ring-cluster
8590
environment:
8691
- NODES=3

0 commit comments

Comments
 (0)