pool

package
v0.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2014 License: MIT Imports: 1 Imported by: 48

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

A simple connection pool. It will create a small pool of initial connections, and if more connections are needed they will be created on demand. If a connection is returned and the pool is full it will be closed.

func NewOrEmptyPool

func NewOrEmptyPool(network, addr string, size int) *Pool

Calls NewPool, but if there is an error it return a pool of the same size but without any connections pre-initialized (can be used the same way, but if this happens there might be something wrong with the redis instance you're connecting to)

func NewPool

func NewPool(network, addr string, size int) (*Pool, error)

Creates a new Pool whose connections are all created using redis.Dial(network, addr). The size indicates the maximum number of idle connections to have waiting to be used at any given moment

func (*Pool) Empty

func (p *Pool) Empty()

Removes and calls Close() on all the connections currently in the pool. Assuming there are no other connections waiting to be Put back this method effectively closes and cleans up the pool.

func (*Pool) Get

func (p *Pool) Get() (*redis.Client, error)

Retrieves an available redis client. If there are none available it will create a new one on the fly

func (*Pool) Put

func (p *Pool) Put(conn *redis.Client)

Returns a client back to the pool. If the pool is full the client is closed instead. If the client is already closed (due to connection failure or what-have-you) it should not be put back in the pool. The pool will create more connections as needed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL