Skip to content

Commit ead6979

Browse files
authored
Merge branch 'master' into apply-make-fmt
2 parents ae7c543 + 1505939 commit ead6979

40 files changed

+988
-93
lines changed

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323
- name: golangci-lint
24-
uses: golangci/[email protected].0
24+
uses: golangci/[email protected].2

Makefile

Lines changed: 1 addition & 1 deletion
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

Lines changed: 18 additions & 10 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 142 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2658,7 +2658,6 @@ var _ = Describe("Commands", func() {
26582658
Expect(res).To(Equal([]int64{1, 1, -2}))
26592659
})
26602660

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

28162957
Describe("hyperloglog", func() {

docker-compose.yml

Lines changed: 5 additions & 0 deletions
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)