var ErrClosed = errors.New("redis: client is closed")
var ErrPoolTimeout = errors.New("redis: connection pool timeout")
type BadConnError struct {
// contains filtered or unexported fields
}
func (e BadConnError) Error() string
func (e BadConnError) Unwrap() error
type Conn struct { Inited bool // contains filtered or unexported fields }
func NewConn(netConn net.Conn) *Conn
func (cn *Conn) Close() error
func (cn *Conn) RemoteAddr() net.Addr
func (cn *Conn) SetNetConn(netConn net.Conn)
func (cn *Conn) SetUsedAt(tm time.Time)
func (cn *Conn) UsedAt() time.Time
func (cn *Conn) WithReader(timeout time.Duration, fn func(rd *proto.Reader) error) error
func (cn *Conn) WithWriter(timeout time.Duration, fn func(wr *proto.Writer) error) error
func (cn *Conn) Write(b []byte) (int, error)
type ConnPool struct {
// contains filtered or unexported fields
}
func NewConnPool(opt *Options) *ConnPool
func (p *ConnPool) Close() error
func (p *ConnPool) CloseConn(cn *Conn) error
func (p *ConnPool) Filter(fn func(*Conn) bool) error
func (p *ConnPool) Get() (*Conn, error)
Get returns existed connection from the pool or creates a new one.
func (p *ConnPool) IdleLen() int
IdleLen returns number of idle connections.
func (p *ConnPool) Len() int
Len returns total number of connections.
func (p *ConnPool) NewConn() (*Conn, error)
func (p *ConnPool) Put(cn *Conn)
func (p *ConnPool) ReapStaleConns() (int, error)
func (p *ConnPool) Remove(cn *Conn, reason error)
func (p *ConnPool) Stats() *Stats
type Options struct { Dialer func() (net.Conn, error) OnClose func(*Conn) error PoolSize int MinIdleConns int MaxConnAge time.Duration PoolTimeout time.Duration IdleTimeout time.Duration IdleCheckFrequency time.Duration }
type Pooler interface { NewConn() (*Conn, error) CloseConn(*Conn) error Get() (*Conn, error) Put(*Conn) Remove(*Conn, error) Len() int IdleLen() int Stats() *Stats Close() error }
type SingleConnPool struct {
// contains filtered or unexported fields
}
func NewSingleConnPool(pool Pooler) *SingleConnPool
func (p *SingleConnPool) Close() error
func (p *SingleConnPool) CloseConn(cn *Conn) error
func (p *SingleConnPool) Get() (*Conn, error)
func (p *SingleConnPool) IdleLen() int
func (p *SingleConnPool) Len() int
func (p *SingleConnPool) NewConn() (*Conn, error)
func (p *SingleConnPool) Put(cn *Conn)
func (p *SingleConnPool) Remove(cn *Conn, reason error)
func (p *SingleConnPool) Reset() error
func (p *SingleConnPool) SetConn(cn *Conn)
func (p *SingleConnPool) Stats() *Stats
Stats contains pool state information and accumulated stats.
type Stats struct { Hits uint32 // number of times free connection was found in the pool Misses uint32 // number of times free connection was NOT found in the pool Timeouts uint32 // number of times a wait timeout occurred TotalConns uint32 // number of total connections in the pool IdleConns uint32 // number of idle connections in the pool StaleConns uint32 // number of stale connections removed from the pool }
type StickyConnPool struct {
// contains filtered or unexported fields
}
func NewStickyConnPool(pool *ConnPool, reusable bool) *StickyConnPool
func (p *StickyConnPool) Close() error
func (p *StickyConnPool) CloseConn(*Conn) error
func (p *StickyConnPool) Get() (*Conn, error)
func (p *StickyConnPool) IdleLen() int
func (p *StickyConnPool) Len() int
func (p *StickyConnPool) NewConn() (*Conn, error)
func (p *StickyConnPool) Put(cn *Conn)
func (p *StickyConnPool) Remove(cn *Conn, reason error)
func (p *StickyConnPool) Stats() *Stats