Skip to content

Commit 5f619cf

Browse files
authored
Merge branch 'master' into enabling-dialect-2-on-default
2 parents 3bd9950 + 7d55118 commit 5f619cf

File tree

25 files changed

+384
-53
lines changed

25 files changed

+384
-53
lines changed

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Go
22

33
on:
44
push:
5-
branches: [master, v9]
5+
branches: [master, v9, v9.7]
66
pull_request:
7-
branches: [master, v9]
7+
branches: [master, v9, v9.7]
88

99
permissions:
1010
contents: read

.github/workflows/golangci-lint.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ on:
1212

1313
permissions:
1414
contents: read
15+
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
1516

1617
jobs:
1718
golangci:
18-
permissions:
19-
contents: read # for actions/checkout to fetch code
20-
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
2119
name: lint
2220
runs-on: ubuntu-latest
2321
steps:
2422
- uses: actions/checkout@v4
2523
- name: golangci-lint
26-
uses: golangci/golangci-lint-action@v6
24+
uses: golangci/golangci-lint-action@v6.5.0

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ testdata/*
55
*.tar.gz
66
*.dic
77
redis8tests.sh
8+
.vscode

example/del-keys-without-ttl/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.18
55
replace github.com/redis/go-redis/v9 => ../..
66

77
require (
8-
github.com/redis/go-redis/v9 v9.6.2
8+
github.com/redis/go-redis/v9 v9.7.1
99
go.uber.org/zap v1.24.0
1010
)
1111

example/hll/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
replace github.com/redis/go-redis/v9 => ../..
66

7-
require github.com/redis/go-redis/v9 v9.6.2
7+
require github.com/redis/go-redis/v9 v9.7.1
88

99
require (
1010
github.com/cespare/xxhash/v2 v2.3.0 // indirect

example/hset-struct/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Example for setting struct fields as hash fields
2+
3+
To run this example:
4+
5+
```shell
6+
go run .
7+
```

example/hset-struct/go.mod

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module github.com/redis/go-redis/example/scan-struct
2+
3+
go 1.18
4+
5+
replace github.com/redis/go-redis/v9 => ../..
6+
7+
require (
8+
github.com/davecgh/go-spew v1.1.1
9+
github.com/redis/go-redis/v9 v9.6.2
10+
)
11+
12+
require (
13+
github.com/cespare/xxhash/v2 v2.2.0 // indirect
14+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
15+
)

example/hset-struct/go.sum

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
2+
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
3+
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
4+
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
5+
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
6+
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
7+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
8+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
9+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
10+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=

example/hset-struct/main.go

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"time"
6+
7+
"github.com/davecgh/go-spew/spew"
8+
9+
"github.com/redis/go-redis/v9"
10+
)
11+
12+
type Model struct {
13+
Str1 string `redis:"str1"`
14+
Str2 string `redis:"str2"`
15+
Str3 *string `redis:"str3"`
16+
Str4 *string `redis:"str4"`
17+
Bytes []byte `redis:"bytes"`
18+
Int int `redis:"int"`
19+
Int2 *int `redis:"int2"`
20+
Int3 *int `redis:"int3"`
21+
Bool bool `redis:"bool"`
22+
Bool2 *bool `redis:"bool2"`
23+
Bool3 *bool `redis:"bool3"`
24+
Bool4 *bool `redis:"bool4,omitempty"`
25+
Time time.Time `redis:"time"`
26+
Time2 *time.Time `redis:"time2"`
27+
Time3 *time.Time `redis:"time3"`
28+
Ignored struct{} `redis:"-"`
29+
}
30+
31+
func main() {
32+
ctx := context.Background()
33+
34+
rdb := redis.NewClient(&redis.Options{
35+
Addr: ":6379",
36+
})
37+
38+
_ = rdb.FlushDB(ctx).Err()
39+
40+
t := time.Date(2025, 02, 8, 0, 0, 0, 0, time.UTC)
41+
42+
data := Model{
43+
Str1: "hello",
44+
Str2: "world",
45+
Str3: ToPtr("hello"),
46+
Str4: nil,
47+
Bytes: []byte("this is bytes !"),
48+
Int: 123,
49+
Int2: ToPtr(0),
50+
Int3: nil,
51+
Bool: true,
52+
Bool2: ToPtr(false),
53+
Bool3: nil,
54+
Time: t,
55+
Time2: ToPtr(t),
56+
Time3: nil,
57+
Ignored: struct{}{},
58+
}
59+
60+
// Set some fields.
61+
if _, err := rdb.Pipelined(ctx, func(rdb redis.Pipeliner) error {
62+
rdb.HMSet(ctx, "key", data)
63+
return nil
64+
}); err != nil {
65+
panic(err)
66+
}
67+
68+
var model1, model2 Model
69+
70+
// Scan all fields into the model.
71+
if err := rdb.HGetAll(ctx, "key").Scan(&model1); err != nil {
72+
panic(err)
73+
}
74+
75+
// Or scan a subset of the fields.
76+
if err := rdb.HMGet(ctx, "key", "str1", "int").Scan(&model2); err != nil {
77+
panic(err)
78+
}
79+
80+
spew.Dump(model1)
81+
// Output:
82+
// (main.Model) {
83+
// Str1: (string) (len=5) "hello",
84+
// Str2: (string) (len=5) "world",
85+
// Str3: (*string)(0xc000016970)((len=5) "hello"),
86+
// Str4: (*string)(0xc000016980)(""),
87+
// Bytes: ([]uint8) (len=15 cap=16) {
88+
// 00000000 74 68 69 73 20 69 73 20 62 79 74 65 73 20 21 |this is bytes !|
89+
// },
90+
// Int: (int) 123,
91+
// Int2: (*int)(0xc000014568)(0),
92+
// Int3: (*int)(0xc000014560)(0),
93+
// Bool: (bool) true,
94+
// Bool2: (*bool)(0xc000014570)(false),
95+
// Bool3: (*bool)(0xc000014548)(false),
96+
// Bool4: (*bool)(<nil>),
97+
// Time: (time.Time) 2025-02-08 00:00:00 +0000 UTC,
98+
// Time2: (*time.Time)(0xc0000122a0)(2025-02-08 00:00:00 +0000 UTC),
99+
// Time3: (*time.Time)(0xc000012288)(0001-01-01 00:00:00 +0000 UTC),
100+
// Ignored: (struct {}) {
101+
// }
102+
// }
103+
104+
spew.Dump(model2)
105+
// Output:
106+
// (main.Model) {
107+
// Str1: (string) (len=5) "hello",
108+
// Str2: (string) "",
109+
// Str3: (*string)(<nil>),
110+
// Str4: (*string)(<nil>),
111+
// Bytes: ([]uint8) <nil>,
112+
// Int: (int) 123,
113+
// Int2: (*int)(<nil>),
114+
// Int3: (*int)(<nil>),
115+
// Bool: (bool) false,
116+
// Bool2: (*bool)(<nil>),
117+
// Bool3: (*bool)(<nil>),
118+
// Bool4: (*bool)(<nil>),
119+
// Time: (time.Time) 0001-01-01 00:00:00 +0000 UTC,
120+
// Time2: (*time.Time)(<nil>),
121+
// Time3: (*time.Time)(<nil>),
122+
// Ignored: (struct {}) {
123+
// }
124+
// }
125+
}
126+
127+
func ToPtr[T any](v T) *T {
128+
return &v
129+
}

example/lua-scripting/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
replace github.com/redis/go-redis/v9 => ../..
66

7-
require github.com/redis/go-redis/v9 v9.6.2
7+
require github.com/redis/go-redis/v9 v9.7.1
88

99
require (
1010
github.com/cespare/xxhash/v2 v2.3.0 // indirect

example/otel/go.mod

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ replace github.com/redis/go-redis/extra/redisotel/v9 => ../../extra/redisotel
99
replace github.com/redis/go-redis/extra/rediscmd/v9 => ../../extra/rediscmd
1010

1111
require (
12-
github.com/redis/go-redis/extra/redisotel/v9 v9.6.2
13-
github.com/redis/go-redis/v9 v9.6.2
12+
github.com/redis/go-redis/extra/redisotel/v9 v9.7.1
13+
github.com/redis/go-redis/v9 v9.7.1
1414
github.com/uptrace/uptrace-go v1.21.0
1515
go.opentelemetry.io/otel v1.22.0
1616
)
@@ -23,7 +23,7 @@ require (
2323
github.com/go-logr/stdr v1.2.2 // indirect
2424
github.com/golang/protobuf v1.5.3 // indirect
2525
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
26-
github.com/redis/go-redis/extra/rediscmd/v9 v9.6.2 // indirect
26+
github.com/redis/go-redis/extra/rediscmd/v9 v9.7.1 // indirect
2727
go.opentelemetry.io/contrib/instrumentation/runtime v0.46.1 // indirect
2828
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.44.0 // indirect
2929
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect

example/redis-bloom/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
replace github.com/redis/go-redis/v9 => ../..
66

7-
require github.com/redis/go-redis/v9 v9.6.2
7+
require github.com/redis/go-redis/v9 v9.7.1
88

99
require (
1010
github.com/cespare/xxhash/v2 v2.3.0 // indirect

example/scan-struct/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ replace github.com/redis/go-redis/v9 => ../..
66

77
require (
88
github.com/davecgh/go-spew v1.1.1
9-
github.com/redis/go-redis/v9 v9.6.2
9+
github.com/redis/go-redis/v9 v9.7.1
1010
)
1111

1212
require (

example/scan-struct/main.go

+6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ import (
1111
type Model struct {
1212
Str1 string `redis:"str1"`
1313
Str2 string `redis:"str2"`
14+
Str3 *string `redis:"str3"`
1415
Bytes []byte `redis:"bytes"`
1516
Int int `redis:"int"`
17+
Int2 *int `redis:"int2"`
1618
Bool bool `redis:"bool"`
19+
Bool2 *bool `redis:"bool2"`
1720
Ignored struct{} `redis:"-"`
1821
}
1922

@@ -29,8 +32,11 @@ func main() {
2932
if _, err := rdb.Pipelined(ctx, func(rdb redis.Pipeliner) error {
3033
rdb.HSet(ctx, "key", "str1", "hello")
3134
rdb.HSet(ctx, "key", "str2", "world")
35+
rdb.HSet(ctx, "key", "str3", "")
3236
rdb.HSet(ctx, "key", "int", 123)
37+
rdb.HSet(ctx, "key", "int2", 0)
3338
rdb.HSet(ctx, "key", "bool", 1)
39+
rdb.HSet(ctx, "key", "bool2", 0)
3440
rdb.HSet(ctx, "key", "bytes", []byte("this is bytes !"))
3541
return nil
3642
}); err != nil {

extra/rediscensus/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ replace github.com/redis/go-redis/v9 => ../..
77
replace github.com/redis/go-redis/extra/rediscmd/v9 => ../rediscmd
88

99
require (
10-
github.com/redis/go-redis/extra/rediscmd/v9 v9.6.2
11-
github.com/redis/go-redis/v9 v9.6.2
10+
github.com/redis/go-redis/extra/rediscmd/v9 v9.7.1
11+
github.com/redis/go-redis/v9 v9.7.1
1212
go.opencensus.io v0.24.0
1313
)
1414

extra/rediscmd/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ replace github.com/redis/go-redis/v9 => ../..
77
require (
88
github.com/bsm/ginkgo/v2 v2.12.0
99
github.com/bsm/gomega v1.27.10
10-
github.com/redis/go-redis/v9 v9.6.2
10+
github.com/redis/go-redis/v9 v9.7.1
1111
)
1212

1313
require (

extra/redisotel/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ replace github.com/redis/go-redis/v9 => ../..
77
replace github.com/redis/go-redis/extra/rediscmd/v9 => ../rediscmd
88

99
require (
10-
github.com/redis/go-redis/extra/rediscmd/v9 v9.6.2
11-
github.com/redis/go-redis/v9 v9.6.2
10+
github.com/redis/go-redis/extra/rediscmd/v9 v9.7.1
11+
github.com/redis/go-redis/v9 v9.7.1
1212
go.opentelemetry.io/otel v1.22.0
1313
go.opentelemetry.io/otel/metric v1.22.0
1414
go.opentelemetry.io/otel/sdk v1.22.0

extra/redisprometheus/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ replace github.com/redis/go-redis/v9 => ../..
66

77
require (
88
github.com/prometheus/client_golang v1.14.0
9-
github.com/redis/go-redis/v9 v9.6.2
9+
github.com/redis/go-redis/v9 v9.7.1
1010
)
1111

1212
require (

0 commit comments

Comments
 (0)