Removed extra OpenTelemetry spans from go-redis core. Now go-redis instrumentation only adds a single span with a Redis command (instead of 4 spans). There are multiple reasons behind this decision:
Eventually we hope to replace the information that we no longer collect with OpenTelemetry Metrics.
PubSub.Channel
to only rely on Ping
result. You can now use WithChannelSize
,
WithChannelHealthCheckInterval
, and WithChannelSendTimeout
to override default settings.To make updating easier, extra modules now have the same version as go-redis does. That means that you need to update your imports:
github.com/go-redis/redis/extra/redisotel -> github.com/go-redis/redis/extra/redisotel/v8
github.com/go-redis/redis/extra/rediscensus -> github.com/go-redis/redis/extra/rediscensus/v8
knadh contributed long-awaited ability to scan Redis Hash into a struct:
err := rdb.HGetAll(ctx, "hash").Scan(&data)
err := rdb.MGet(ctx, "key1", "key2").Scan(&data)
Please check redismock by monkey92t if you are looking for mocking Redis Client.
All commands require context.Context
as a first argument, e.g. rdb.Ping(ctx)
. If you are not
using context.Context
yet, the simplest option is to define global package variable
var ctx = context.TODO()
and use it when ctx
is required.
Full support for context.Context
canceling.
Added redis.NewFailoverClusterClient
that supports routing read-only commands to a slave node.
Added redisext.OpenTemetryHook
that adds
Redis OpenTelemetry instrumentation.
Redis slow log support.
Ring uses Rendezvous Hashing by default which provides better distribution. You need to move existing keys to a new location or keys will be inaccessible / lost. To use old hashing scheme:
import "github.com/golang/groupcache/consistenthash"
ring := redis.NewRing(&redis.RingOptions{
NewConsistentHash: func() {
return consistenthash.New(100, crc32.ChecksumIEEE)
},
})
ClusterOptions.MaxRedirects
default value is changed from 8 to 3.
Options.MaxRetries
default value is changed from 0 to 3.
Cluster.ForEachNode
is renamed to ForEachShard
for consistency with Ring
.
Options.Username
which causes client to use AuthACL
. Be aware if your connection
URL contains username.HMSet
is renamed to HSet
and old deprecated HMSet
is restored for Redis 3 users.Cmd.String
is renamed to Cmd.Text
. New Cmd.String
implements fmt.Stringer
interface.*Subscription
in addition to *Message
to allow
detecting reconnections.time.Time
is now marshalled in RFC3339 format. rdb.Get("foo").Time()
helper is added to parse
the time.SetLimiter
is removed and added Options.Limiter
instead.HMSet
is deprecated as of Redis v4.HashReplicas
and Hash
. It is recommended to set
HashReplicas = 1000
for better keys distribution between shards.ClusterSlots
which allows to build cluster of normal Redis
Servers that don't have cluster mode enabled. See
https://godoc.org/github.com/go-redis/redis#example-NewClusterClient--ManualSetup