You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use go-redis v8 NewClusterClient, create a client and use Get to get the key data, and set the context timeout, the context takes effect, but the Get command takes longer than the context timeout
127.0.0.1:30001 is available. In the Get function, I pause the program for 500ms when getting the link to simulate the delay time of the redis cluster. The code is as follows
func (p *ConnPool) popIdle() (*Conn, error) {
if p.closed() {
return nil, ErrClosed
}
n := len(p.idleConns)
if n == 0 {
return nil, nil
}
var cn *Conn
if p.opt.PoolFIFO {
cn = p.idleConns[0]
copy(p.idleConns, p.idleConns[1:])
p.idleConns = p.idleConns[:n-1]
} else {
idx := n - 1
cn = p.idleConns[idx]
p.idleConns = p.idleConns[:idx]
time.Sleep(500*time.Millisecond)
}
p.idleConnsLen--
p.checkMinIdleConns()
return cn, nil
}
The text was updated successfully, but these errors were encountered:
When I use go-redis v8 NewClusterClient, create a client and use Get to get the key data, and set the context timeout, the context takes effect, but the Get command takes longer than the context timeout
demo As above, the result I get is:
=== RUN TestGoRedis
context deadline exceeded
603ms
--- PASS: TestGoRedis (0.60s)
PASS
gomod: github.com/go-redis/redis/v8 v8.11.5
127.0.0.1:30001 is available. In the Get function, I pause the program for 500ms when getting the link to simulate the delay time of the redis cluster. The code is as follows
The text was updated successfully, but these errors were encountered: