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:
15
redis.go
15
redis.go
@ -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) {
|
||||
|
Reference in New Issue
Block a user