Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- "8.2.x" # Redis CE 8.2
- "8.0.x" # Redis CE 8.0
go-version:
- "1.21.x"
- "1.23.x"
- "1.24.x"

Expand Down Expand Up @@ -78,6 +79,7 @@ jobs:
- "8.2.x" # Redis CE 8.2
- "8.0.x" # Redis CE 8.0
go-version:
- "1.21.x"
- "1.23.x"
- "1.24.x"

Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ In `go-redis` we are aiming to support the last three releases of Redis. Current
- [Redis 8.2](https://raw.githubusercontent.com/redis/redis/8.2/00-RELEASENOTES) - using Redis CE 8.2
- [Redis 8.4](https://raw.githubusercontent.com/redis/redis/8.4/00-RELEASENOTES) - using Redis CE 8.4

Although the `go.mod` states it requires at minimum `go 1.18`, our CI is configured to run the tests against all three
versions of Redis and latest two versions of Go ([1.23](https://go.dev/doc/devel/release#go1.23.0),
[1.24](https://go.dev/doc/devel/release#go1.24.0)). We observe that some modules related test may not pass with
Although the `go.mod` states it requires at minimum `go 1.21`, our CI is configured to run the tests against all three
versions of Redis and multiple versions of Go ([1.21](https://go.dev/doc/devel/release#go1.21.0),
[1.23](https://go.dev/doc/devel/release#go1.23.0), [1.24](https://go.dev/doc/devel/release#go1.24.0)). We observe that some modules related test may not pass with
Redis Stack 7.2 and some commands are changed with Redis CE 8.0.
Although it is not officially supported, `go-redis/v9` should be able to work with any Redis 7.0+.
Please do refer to the documentation and the tests if you experience any issues. We do plan to update the go version
in the `go.mod` to `go 1.24` in one of the next releases.
Please do refer to the documentation and the tests if you experience any issues.

## How do I Redis?

Expand Down
24 changes: 16 additions & 8 deletions doctests/timeseries_tut_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@ package example_commands_test
import (
"context"
"fmt"
"maps"
"math"
"slices"
"sort"

"github.com/redis/go-redis/v9"
)

// HIDE_END

// mapKeys returns a slice of all keys from the map (Go 1.21 compatible)
// TODO: Once minimum Go version is upgraded to 1.23+, replace with slices.Collect(maps.Keys(m))
func mapKeys[K comparable, V any](m map[K]V) []K {
keys := make([]K, 0, len(m))
for k := range m {
keys = append(keys, k)
}
return keys
}

func ExampleClient_timeseries_create() {
ctx := context.Background()

Expand Down Expand Up @@ -417,7 +425,7 @@ func ExampleClient_timeseries_query_multi() {
panic(err)
}

res28Keys := slices.Collect(maps.Keys(res28))
res28Keys := mapKeys(res28)
sort.Strings(res28Keys)

for _, k := range res28Keys {
Expand Down Expand Up @@ -457,7 +465,7 @@ func ExampleClient_timeseries_query_multi() {
panic(err)
}

res29Keys := slices.Collect(maps.Keys(res29))
res29Keys := mapKeys(res29)
sort.Strings(res29Keys)

for _, k := range res29Keys {
Expand Down Expand Up @@ -505,7 +513,7 @@ func ExampleClient_timeseries_query_multi() {
panic(err)
}

res30Keys := slices.Collect(maps.Keys(res30))
res30Keys := mapKeys(res30)
sort.Strings(res30Keys)

for _, k := range res30Keys {
Expand Down Expand Up @@ -550,7 +558,7 @@ func ExampleClient_timeseries_query_multi() {
panic(err)
}

res31Keys := slices.Collect(maps.Keys(res31))
res31Keys := mapKeys(res31)
sort.Strings(res31Keys)

for _, k := range res31Keys {
Expand Down Expand Up @@ -857,7 +865,7 @@ func ExampleClient_timeseries_aggmulti() {
panic(err)
}

res44Keys := slices.Collect(maps.Keys(res44))
res44Keys := mapKeys(res44)
sort.Strings(res44Keys)

for _, k := range res44Keys {
Expand Down Expand Up @@ -905,7 +913,7 @@ func ExampleClient_timeseries_aggmulti() {
panic(err)
}

res45Keys := slices.Collect(maps.Keys(res45))
res45Keys := mapKeys(res45)
sort.Strings(res45Keys)

for _, k := range res45Keys {
Expand Down
2 changes: 1 addition & 1 deletion example/cluster-mget/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redis/go-redis/example/cluster-mget

go 1.18
go 1.21

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

Expand Down
2 changes: 1 addition & 1 deletion example/del-keys-without-ttl/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redis/go-redis/example/del-keys-without-ttl

go 1.18
go 1.21

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

Expand Down
2 changes: 1 addition & 1 deletion example/digest-optimistic-locking/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redis/go-redis/example/digest-optimistic-locking

go 1.18
go 1.21

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

Expand Down
2 changes: 1 addition & 1 deletion example/hll/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redis/go-redis/example/hll

go 1.18
go 1.21

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

Expand Down
2 changes: 1 addition & 1 deletion example/hset-struct/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redis/go-redis/example/scan-struct

go 1.18
go 1.21

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

Expand Down
2 changes: 1 addition & 1 deletion example/lua-scripting/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redis/go-redis/example/lua-scripting

go 1.18
go 1.21

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

Expand Down
2 changes: 1 addition & 1 deletion example/maintnotifiations-pubsub/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redis/go-redis/example/pubsub

go 1.18
go 1.21

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

Expand Down
2 changes: 1 addition & 1 deletion example/redis-bloom/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redis/go-redis/example/redis-bloom

go 1.18
go 1.21

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

Expand Down
2 changes: 1 addition & 1 deletion example/scan-struct/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redis/go-redis/example/scan-struct

go 1.18
go 1.21

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

Expand Down
2 changes: 1 addition & 1 deletion extra/rediscensus/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redis/go-redis/extra/rediscensus/v9

go 1.19
go 1.21

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

Expand Down
2 changes: 1 addition & 1 deletion extra/rediscmd/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redis/go-redis/extra/rediscmd/v9

go 1.19
go 1.21

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

Expand Down
2 changes: 1 addition & 1 deletion extra/redisotel/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redis/go-redis/extra/redisotel/v9

go 1.19
go 1.21

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

Expand Down
2 changes: 1 addition & 1 deletion extra/redisprometheus/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redis/go-redis/extra/redisprometheus/v9

go 1.19
go 1.21

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

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redis/go-redis/v9

go 1.18
go 1.21

require (
github.com/bsm/ginkgo/v2 v2.12.0
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
2 changes: 1 addition & 1 deletion internal/customvet/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/redis/go-redis/internal/customvet

go 1.17
go 1.21

require golang.org/x/tools v0.5.0

Expand Down
38 changes: 34 additions & 4 deletions internal/routing/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,25 @@ func (a *AggLogicalAndAggregator) Add(result interface{}, err error) error {
return e
}

// Atomic AND operation using CompareAndSwap loop (Go 1.21 compatible)
// TODO: Once minimum Go version is upgraded to 1.23+, replace this with:
// if val { a.res.And(1) } else { a.res.And(0) }
var newVal int64
if val {
a.res.And(1)
newVal = 1
} else {
a.res.And(0)
newVal = 0
}
for {
old := a.res.Load()
desired := old & newVal
if a.res.CompareAndSwap(old, desired) {
break
}
// Early exit: if the value already equals what we want, no need to continue
if a.res.Load() == desired {
break
}
}

a.hasResult.Store(true)
Expand Down Expand Up @@ -566,10 +581,25 @@ func (a *AggLogicalOrAggregator) Add(result interface{}, err error) error {
return e
}

// Atomic OR operation using CompareAndSwap loop (Go 1.21 compatible)
// TODO: Once minimum Go version is upgraded to 1.23+, replace this with:
// if val { a.res.Or(1) } else { a.res.Or(0) }
var newVal int64
if val {
a.res.Or(1)
newVal = 1
} else {
a.res.Or(0)
newVal = 0
}
for {
old := a.res.Load()
desired := old | newVal
if a.res.CompareAndSwap(old, desired) {
break
}
// Early exit: if the value already equals what we want, no need to continue
if a.res.Load() == desired {
break
}
}

a.hasResult.Store(true)
Expand Down
6 changes: 3 additions & 3 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ PACKAGE_DIRS=$(find . -mindepth 2 -type f -name 'go.mod' -exec dirname {} \; \
for dir in $PACKAGE_DIRS
do
printf "${dir}: go get -u && go mod tidy\n"
#(cd ./${dir} && go get -u && go mod tidy -compat=1.18)
#(cd ./${dir} && go get -u && go mod tidy -compat=1.21)
done

for dir in $PACKAGE_DIRS
do
sed --in-place \
"s/redis\/go-redis\([^ ]*\) v.*/redis\/go-redis\1 ${TAG}/" "${dir}/go.mod"
#(cd ./${dir} && go get -u && go mod tidy -compat=1.18)
(cd ./${dir} && go mod tidy -compat=1.18)
#(cd ./${dir} && go get -u && go mod tidy -compat=1.21)
(cd ./${dir} && go mod tidy -compat=1.21)
done

sed --in-place "s/\(return \)\"[^\"]*\"/\1\"${TAG#v}\"/" ./version.go
Expand Down
Loading