1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Add MaxConnAge

This commit is contained in:
Vladimir Mihailenco
2018-08-12 10:08:21 +03:00
parent 52d9bc3a1e
commit 651e9fef1d
12 changed files with 170 additions and 123 deletions

View File

@ -18,9 +18,9 @@ type Conn struct {
concurrentReadWrite bool
Inited bool
pooled bool
usedAt atomic.Value
InitedAt time.Time
pooled bool
usedAt atomic.Value
}
func NewConn(netConn net.Conn) *Conn {
@ -47,10 +47,6 @@ func (cn *Conn) SetNetConn(netConn net.Conn) {
cn.Rd.Reset(netConn)
}
func (cn *Conn) IsStale(timeout time.Duration) bool {
return timeout > 0 && time.Since(cn.UsedAt()) > timeout
}
func (cn *Conn) SetReadTimeout(timeout time.Duration) {
now := time.Now()
cn.SetUsedAt(now)