1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

Make free-connection stack a LIFO.

This commit is contained in:
Dimitrij Denissenko
2016-03-12 13:39:50 +02:00
committed by Vladimir Mihailenco
parent 7a4f8ede8f
commit 1bb55e3a9a
3 changed files with 103 additions and 37 deletions

View File

@ -35,6 +35,10 @@ func NewConn(netConn net.Conn) *Conn {
return cn
}
func (cn *Conn) IsStale(timeout time.Duration) bool {
return timeout > 0 && time.Since(cn.UsedAt) > timeout
}
func (cn *Conn) SetNetConn(netConn net.Conn) {
cn.netConn = netConn
cn.UsedAt = time.Now()