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:
@ -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)
|
||||
|
Reference in New Issue
Block a user