42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package 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 connections allocated by the pool at a given time.
|
|
// When zero, there is no limit on the number of connections in the pool.
|
|
GetMaxCapacity() int
|
|
|
|
// Maximum number of idle connections in the pool.
|
|
GetMaxIdle() 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
|
|
|
|
Validate()
|
|
}
|