40 lines
1.3 KiB
Go
40 lines
1.3 KiB
Go
|
package overflow_redis_pool
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
|
||
|
"github.com/garyburd/redigo/redis"
|
||
|
)
|
||
|
|
||
|
type PoolHandler interface {
|
||
|
// Dial is an application supplied function for creating and configuring a
|
||
|
// connection.
|
||
|
//
|
||
|
// The connection returned from Dial must not be in a special state
|
||
|
// (subscribed to pubsub channel, transaction started, ...).
|
||
|
Dial() (redis.Conn, error)
|
||
|
|
||
|
// TestOnBorrow is an optional application supplied function for checking
|
||
|
// the health of an idle connection before the connection is used again by
|
||
|
// the application. Argument t is the time that the connection was returned
|
||
|
// to the pool. If the function returns an error, then the connection is
|
||
|
// closed.
|
||
|
TestOnBorrow(c redis.Conn, t time.Time) error
|
||
|
|
||
|
// Maximum number of idle connections in the pool.
|
||
|
GetMaxIdle() int
|
||
|
|
||
|
// 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.
|
||
|
GetMaxActive() 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.
|
||
|
GetIdleTimeout() 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.
|
||
|
IsWait() bool
|
||
|
}
|