package pool
import "github.com/go-redis/redis/internal/pool"
Index ¶
- Variables
- type Conn
- func NewConn(netConn net.Conn) *Conn
- func (cn *Conn) Close() int
- func (cn *Conn) Index() int
- func (cn *Conn) IsStale(timeout time.Duration) bool
- func (cn *Conn) Read(b []byte) (int, error)
- func (cn *Conn) RemoteAddr() net.Addr
- func (cn *Conn) SetIndex(idx int)
- func (cn *Conn) Write(b []byte) (int, error)
- type ConnPool
- func NewConnPool(dial dialer, poolSize int, poolTimeout, idleTimeout time.Duration) *ConnPool
- func (p *ConnPool) Add(cn *Conn) bool
- func (p *ConnPool) Close() (retErr error)
- func (p *ConnPool) Closed() bool
- func (p *ConnPool) First() *Conn
- func (p *ConnPool) FreeLen() int
- func (p *ConnPool) Get() (cn *Conn, isNew bool, err error)
- func (p *ConnPool) Len() int
- func (p *ConnPool) Put(cn *Conn) error
- func (p *ConnPool) ReapStaleConns() (n int, err error)
- func (p *ConnPool) Remove(cn *Conn, reason error) error
- func (p *ConnPool) Replace(cn *Conn, reason error) error
- func (p *ConnPool) Stats() *PoolStats
- type PoolStats
- type Pooler
- type SingleConnPool
- func NewSingleConnPool(cn *Conn) *SingleConnPool
- func (p *SingleConnPool) Close() error
- func (p *SingleConnPool) Closed() bool
- func (p *SingleConnPool) First() *Conn
- func (p *SingleConnPool) FreeLen() int
- func (p *SingleConnPool) Get() (*Conn, bool, error)
- func (p *SingleConnPool) Len() int
- func (p *SingleConnPool) Put(cn *Conn) error
- func (p *SingleConnPool) Replace(cn *Conn, _ error) error
- func (p *SingleConnPool) Stats() *PoolStats
- type StickyConnPool
- func NewStickyConnPool(pool *ConnPool, reusable bool) *StickyConnPool
- func (p *StickyConnPool) Close() error
- func (p *StickyConnPool) Closed() bool
- func (p *StickyConnPool) First() *Conn
- func (p *StickyConnPool) FreeLen() int
- func (p *StickyConnPool) Get() (cn *Conn, isNew bool, err error)
- func (p *StickyConnPool) Len() int
- func (p *StickyConnPool) Put(cn *Conn) error
- func (p *StickyConnPool) Replace(cn *Conn, reason error) error
- func (p *StickyConnPool) Stats() *PoolStats
Variables ¶
var ( ErrClosed = errors.New("redis: client is closed") ErrPoolTimeout = errors.New("redis: connection pool timeout") )
Types ¶
type Conn ¶
type Conn struct { NetConn net.Conn Rd *bufio.Reader Buf []byte UsedAt time.Time ReadTimeout time.Duration WriteTimeout time.Duration // contains filtered or unexported fields }
func NewConn ¶
func (*Conn) Close ¶
func (*Conn) Index ¶
func (*Conn) IsStale ¶
func (*Conn) Read ¶
func (*Conn) RemoteAddr ¶
func (*Conn) SetIndex ¶
func (*Conn) Write ¶
type ConnPool ¶
type ConnPool struct { DialLimiter *ratelimit.RateLimiter // contains filtered or unexported fields }
func NewConnPool ¶
func (*ConnPool) Add ¶
func (*ConnPool) Close ¶
func (*ConnPool) Closed ¶
func (*ConnPool) First ¶
First returns first non-idle connection from the pool or nil if there are no connections.
func (*ConnPool) FreeLen ¶
FreeLen returns number of free connections.
func (*ConnPool) Get ¶
Get returns existed connection from the pool or creates a new one.
func (*ConnPool) Len ¶
Len returns total number of connections.
func (*ConnPool) Put ¶
func (*ConnPool) ReapStaleConns ¶
func (*ConnPool) Remove ¶
func (*ConnPool) Replace ¶
func (*ConnPool) Stats ¶
type PoolStats ¶
type PoolStats struct { Requests uint32 // number of times a connection was requested by the pool Hits uint32 // number of times free connection was found in the pool Waits uint32 // number of times the pool had to wait for a connection Timeouts uint32 // number of times a wait timeout occurred TotalConns uint32 // the number of total connections in the pool FreeConns uint32 // the number of free connections in the pool }
PoolStats contains pool state information and accumulated stats.
type Pooler ¶
type Pooler interface { First() *Conn Get() (*Conn, bool, error) Put(*Conn) error Replace(*Conn, error) error Len() int FreeLen() int Stats() *PoolStats Close() error Closed() bool }
type SingleConnPool ¶
type SingleConnPool struct {
// contains filtered or unexported fields
}
func NewSingleConnPool ¶
func NewSingleConnPool(cn *Conn) *SingleConnPool
func (*SingleConnPool) Close ¶
func (p *SingleConnPool) Close() error
func (*SingleConnPool) Closed ¶
func (p *SingleConnPool) Closed() bool
func (*SingleConnPool) First ¶
func (p *SingleConnPool) First() *Conn
func (*SingleConnPool) FreeLen ¶
func (p *SingleConnPool) FreeLen() int
func (*SingleConnPool) Get ¶
func (p *SingleConnPool) Get() (*Conn, bool, error)
func (*SingleConnPool) Len ¶
func (p *SingleConnPool) Len() int
func (*SingleConnPool) Put ¶
func (p *SingleConnPool) Put(cn *Conn) error
func (*SingleConnPool) Replace ¶
func (p *SingleConnPool) Replace(cn *Conn, _ error) error
func (*SingleConnPool) Stats ¶
func (p *SingleConnPool) Stats() *PoolStats
type StickyConnPool ¶
type StickyConnPool struct {
// contains filtered or unexported fields
}
func NewStickyConnPool ¶
func NewStickyConnPool(pool *ConnPool, reusable bool) *StickyConnPool
func (*StickyConnPool) Close ¶
func (p *StickyConnPool) Close() error
func (*StickyConnPool) Closed ¶
func (p *StickyConnPool) Closed() bool
func (*StickyConnPool) First ¶
func (p *StickyConnPool) First() *Conn
func (*StickyConnPool) FreeLen ¶
func (p *StickyConnPool) FreeLen() int
func (*StickyConnPool) Get ¶
func (p *StickyConnPool) Get() (cn *Conn, isNew bool, err error)
func (*StickyConnPool) Len ¶
func (p *StickyConnPool) Len() int
func (*StickyConnPool) Put ¶
func (p *StickyConnPool) Put(cn *Conn) error
func (*StickyConnPool) Replace ¶
func (p *StickyConnPool) Replace(cn *Conn, reason error) error
func (*StickyConnPool) Stats ¶
func (p *StickyConnPool) Stats() *PoolStats
Source Files ¶
conn.go conn_list.go conn_stack.go pool.go pool_single.go pool_sticky.go
- Version
- v3.5.2+incompatible
- Published
- Mar 14, 2016
- Platform
- linux/amd64
- Imports
- 9 packages
- Last checked
- 5 hours ago –
Tools for package owners.