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

Faster and simpler pool.

This commit is contained in:
Vladimir Mihailenco
2016-03-17 18:00:47 +02:00
parent 93a7fe0de3
commit 6e1aef39ea
22 changed files with 418 additions and 492 deletions

View File

@ -50,6 +50,9 @@ type Options struct {
// connections. Should be less than server's timeout.
// Default is to not close idle connections.
IdleTimeout time.Duration
// The frequency of idle checks.
// Default is 1 minute.
IdleCheckFrequency time.Duration
}
func (opt *Options) getNetwork() string {
@ -93,9 +96,21 @@ func (opt *Options) getIdleTimeout() time.Duration {
return opt.IdleTimeout
}
func (opt *Options) getIdleCheckFrequency() time.Duration {
if opt.IdleCheckFrequency == 0 {
return time.Minute
}
return opt.IdleCheckFrequency
}
func newConnPool(opt *Options) *pool.ConnPool {
return pool.NewConnPool(
opt.getDialer(), opt.getPoolSize(), opt.getPoolTimeout(), opt.getIdleTimeout())
opt.getDialer(),
opt.getPoolSize(),
opt.getPoolTimeout(),
opt.getIdleTimeout(),
opt.getIdleCheckFrequency(),
)
}
// PoolStats contains pool state information and accumulated stats.