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

Simplify connection management with sticky connection pool. Fixes #260.

This commit is contained in:
Vladimir Mihailenco
2016-03-01 12:31:06 +02:00
parent 0382d1e980
commit 110e93a8e4
10 changed files with 140 additions and 90 deletions

View File

@ -23,15 +23,20 @@ func (c *baseClient) conn() (*conn, bool, error) {
return c.connPool.Get()
}
func (c *baseClient) putConn(cn *conn, err error) {
if isBadConn(cn, err) {
func (c *baseClient) putConn(cn *conn, err error) bool {
if isBadConn(err) {
err = c.connPool.Remove(cn, err)
} else {
err = c.connPool.Put(cn)
if err != nil {
log.Printf("pool.Remove failed: %s", err)
}
return false
}
err = c.connPool.Put(cn)
if err != nil {
Logger.Printf("pool.Put failed: %s", err)
log.Printf("pool.Put failed: %s", err)
}
return true
}
func (c *baseClient) process(cmd Cmder) {