- All commands require
context.Context
as a first argument, e.g.rdb.Ping(ctx)
. If you are not usingcontext.Context
yet, the simplest option is to define package variablevar ctx = context.TODO()
and use it whenctx
is expected. - Ring uses Rendezvous Hashing by default which provides better distribution. This means that existing keys must be moved to a new location or key will be inaccessible / lost. To use old hashing scheme:
Cluster.ForEachNode
is renamed toForEachShard
for consistency withRing
.
import "github.com/golang/groupcache/consistenthash"
ring := redis.NewRing(&redis.RingOptions{
NewConsistentHash: func() {
return consistenthash.New(100, crc32.ChecksumIEEE)
},
})
- Added
redisext.OpenTemetryHook
that adds Redis OpenTelemetry instrumentation.
- New option
Options.Username
which causes client to useAuthACL
. Be aware if your connection URL contains username.
- Existing
HMSet
is renamed toHSet
and old deprecatedHMSet
is restored for Redis 3 users.
- Existing
Cmd.String
is renamed toCmd.Text
. NewCmd.String
implementsfmt.Stringer
interface.
- Important. Tx.Pipeline now returns a non-transactional pipeline. Use Tx.TxPipeline for a transactional pipeline.
- WrapProcess is replaced with more convenient AddHook that has access to context.Context.
- WithContext now can not be used to create a shallow copy of the client.
- New methods ProcessContext, DoContext, and ExecContext.
- Client respects Context.Deadline when setting net.Conn deadline.
- Client listens on Context.Done while waiting for a connection from the pool and returns an error when context context is cancelled.
- Add PubSub.ChannelWithSubscriptions that sends
*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 addedOptions.Limiter
instead.HMSet
is deprecated as of Redis v4.
- Cluster and Ring pipelines process commands for each node in its own goroutine.
- Added Options.MinIdleConns.
- Added Options.MaxConnAge.
- PoolStats.FreeConns is renamed to PoolStats.IdleConns.
- Add Client.Do to simplify creating custom commands.
- Add Cmd.String, Cmd.Int, Cmd.Int64, Cmd.Uint64, Cmd.Float64, and Cmd.Bool helpers.
- Lower memory usage.
- Ring got new options called
HashReplicas
andHash
. It is recommended to setHashReplicas = 1000
for better keys distribution between shards. - Cluster client was optimized to use much less memory when reloading cluster state.
- PubSub.ReceiveMessage is re-worked to not use ReceiveTimeout so it does not lose data when timeout occurres. In most cases it is recommended to use PubSub.Channel instead.
- Dialer.KeepAlive is set to 5 minutes by default.
- ClusterClient got new option called
ClusterSlots
which allows to build cluster of normal Redis Servers that don't have cluster mode enabled. See https://godoc.org/github.com/natewernimont-wk/redis#example-NewClusterClient--ManualSetup