package redis_pool import ( "fmt" "time" "github.com/garyburd/redigo/redis" ) type PoolHandlers struct { // Maximum number of connections allocated by the pool at a given time. // When zero, there is no limit on the number of connections in the pool. MaxCapacity int // Maximum number of idle connections in the pool. MaxIdle int // Close connections after remaining idle for this duration. If the value // is zero, then idle connections are not closed. Applications should set // the timeout to a value less than the server's timeout. IdleTimeout time.Duration // If Wait is true and the pool is at the MaxActive limit, then Get() waits // for a connection to be returned to the pool before returning. Wait bool } func (ph *PoolHandlers) Dial() (redis.Conn, error) { return nil, fmt.Errorf("Redis Pool: Dial method is not implemented") } func (ph *PoolHandlers) TestOnBorrow(c redis.Conn, t time.Time) error { return nil } func (ph *PoolHandlers) GetMaxCapacity() int { return ph.MaxCapacity } func (ph *PoolHandlers) GetMaxIdle() int { return ph.MaxIdle } func (ph *PoolHandlers) GetIdleTimeout() time.Duration { return ph.IdleTimeout } func (ph *PoolHandlers) IsWait() bool { return ph.Wait } func (ph *PoolHandlers) Validate() { if ph.MaxCapacity <= 0 { ph.MaxCapacity = DefaultMaxCapacity } if ph.MaxIdle <= 0 { ph.MaxIdle = DefaultMaxIdle } if ph.IdleTimeout <= 0 { ph.IdleTimeout = DefaultIdleTimeout } }