mirror of https://github.com/go-redis/redis.git
Tweak auto-reloads
This commit is contained in:
parent
0ffefcde98
commit
64995f9a51
10
cluster.go
10
cluster.go
|
@ -622,7 +622,7 @@ func (c *clusterStateHolder) LazyReload(ctx context.Context) {
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
}()
|
||||
}
|
||||
|
||||
|
@ -630,7 +630,7 @@ func (c *clusterStateHolder) Get(ctx context.Context) (*clusterState, error) {
|
|||
v := c.state.Load()
|
||||
if v != nil {
|
||||
state := v.(*clusterState)
|
||||
if time.Since(state.createdAt) > time.Minute {
|
||||
if time.Since(state.createdAt) > 10*time.Second {
|
||||
c.LazyReload(ctx)
|
||||
}
|
||||
return state, nil
|
||||
|
@ -780,9 +780,6 @@ func (c *ClusterClient) _process(ctx context.Context, cmd Cmder) error {
|
|||
if lastErr == nil {
|
||||
return nil
|
||||
}
|
||||
if lastErr != Nil {
|
||||
c.state.LazyReload(ctx)
|
||||
}
|
||||
if lastErr == pool.ErrClosed || isReadOnlyError(lastErr) {
|
||||
node = nil
|
||||
continue
|
||||
|
@ -1431,9 +1428,6 @@ func (c *ClusterClient) Watch(ctx context.Context, fn func(*Tx) error, keys ...s
|
|||
if err == nil {
|
||||
break
|
||||
}
|
||||
if err != Nil {
|
||||
c.state.LazyReload(ctx)
|
||||
}
|
||||
|
||||
moved, ask, addr := isMovedError(err)
|
||||
if moved || ask {
|
||||
|
|
|
@ -43,8 +43,8 @@ var _ = Describe("HashSlot", func() {
|
|||
{"{}foo", 9500},
|
||||
{"foo{}", 5542},
|
||||
{"foo{}{bar}", 8363},
|
||||
{"", 10503},
|
||||
{"", 5176},
|
||||
{"", 7404},
|
||||
{"", 4403},
|
||||
{string([]byte{83, 153, 134, 118, 229, 214, 244, 75, 140, 37, 215, 215}), 5463},
|
||||
}
|
||||
// Empty keys receive random slot.
|
||||
|
|
Loading…
Reference in New Issue