Documentation
¶
Index ¶
- Variables
- func CreateMemcacheConnection(Instance interface{}) (pools.Resource, error)
- func CreateMySQLConnection(Instance interface{}) (pools.Resource, error)
- func CreateRedisConnection(Instance interface{}) (pools.Resource, error)
- type MemConn
- type Memcache
- func (m *Memcache) Configure(settings PoolSettings)
- func (m *Memcache) Delete(keys ...interface{}) (int, error)
- func (m *Memcache) Execute(cmd string, args ...interface{}) (interface{}, error)
- func (m *Memcache) Expire(key string, duration int) (bool, error)
- func (m *Memcache) Get(key string) (string, error)
- func (m *Memcache) GetClient() *MemConn
- func (m *Memcache) MGet(keys ...interface{}) ([]string, error)
- func (m *Memcache) MSet(keyValMap map[string]interface{}) (bool, error)
- func (m *Memcache) PutClient(c *MemConn)
- func (m *Memcache) SAdd(key string, values ...interface{}) (bool, error)
- func (m *Memcache) SRem(key string, value string) (bool, error)
- func (m *Memcache) Set(key string, value interface{}) (bool, error)
- func (m *Memcache) SetDefaults()
- func (m *Memcache) Setex(key string, duration int, val interface{}) (bool, error)
- func (m *Memcache) Sismember(key string, member string) (bool, error)
- func (m *Memcache) Sismembers(key string, members []string) ([]bool, error)
- func (m *Memcache) Smembers(key string) ([]string, error)
- func (m *Memcache) StatsJSON() string
- type MySQL
- type MySQLConn
- type PoolSettings
- type Redis
- func (r *Redis) Configure(settings PoolSettings)
- func (r *Redis) Delete(keys ...interface{}) (int, error)
- func (r *Redis) Execute(cmd string, args ...interface{}) (interface{}, error)
- func (r *Redis) Expire(key string, duration int) (bool, error)
- func (r *Redis) Get(key string) (string, error)
- func (r *Redis) GetClient() (*RedisConn, error)
- func (r *Redis) MGet(keys ...interface{}) ([]string, error)
- func (r *Redis) MSet(mapOfKeyVal map[string]interface{}) (bool, error)
- func (r *Redis) PutClient(c *RedisConn)
- func (r *Redis) SAdd(key string, values ...interface{}) (bool, error)
- func (r *Redis) SRem(key string, value string) (bool, error)
- func (r *Redis) Set(key string, value interface{}) (bool, error)
- func (r *Redis) SetDefaults()
- func (r *Redis) Setex(key string, duration int, val interface{}) (bool, error)
- func (r *Redis) Sismember(key string, member string) (bool, error)
- func (r *Redis) Sismembers(key string, members []string) ([]bool, error)
- func (r *Redis) Smembers(key string) ([]string, error)
- func (r *Redis) StatsJSON() string
- type RedisConn
- type ResourcePool
Constants ¶
This section is empty.
Variables ¶
var DefaultMemcacheIpAndHost = []string{"localhost:11211"}
var DefaultRedisConfig = []string{"localhost:6379"}
default host:port to connect
var MemcachePoolSize = 50
var MySQLPoolSize = 15
default pool size
var RedisPoolSize = 50
default pool size
Functions ¶
func CreateMySQLConnection ¶
This method creates a MySQL connection CreateMySQLConnection is passed as a callback to pools Instance:
This is a reference to a struct MySQL instance Connect needs some params like db, hostAndPorts These params are read from this instance rederence
func CreateRedisConnection ¶
This method creates a redis connection CreateRedisConnection is passed as a callback to pools Instance:
This is a reference to a struct redis instance Connect needs some params like db, hostAndPorts These params are read from this instance rederence
Types ¶
type Memcache ¶
type Memcache struct { Settings PoolSettings // contains filtered or unexported fields }
func (*Memcache) Configure ¶
func (m *Memcache) Configure(settings PoolSettings)
func (*Memcache) SetDefaults ¶
func (m *Memcache) SetDefaults()
func (*Memcache) Sismembers ¶
type MySQL ¶
type MySQL struct { Settings PoolSettings // contains filtered or unexported fields }
func (*MySQL) Configure ¶
func (m *MySQL) Configure(settings PoolSettings)
func (*MySQL) GetConn ¶
Gets a connection from pool and converts to MySQLConn type If all the connections are in use, timeout the present request after a minute
func (*MySQL) Select ¶
Execute all the methods for a SQL query over here Execute MySQL commands; Also has support for select * from table Gets a client from pool, executes a cmd, puts conn back in pool
func (*MySQL) SetDefaults ¶
func (m *MySQL) SetDefaults()
type PoolSettings ¶
type PoolSettings struct { HostAndPorts []string Capacity int MaxCapacity int Options map[string]string Timeout time.Duration }
This struct has all the generic settings that are required for creating a pool
type Redis ¶
type Redis struct { Settings PoolSettings // contains filtered or unexported fields }
func (*Redis) Configure ¶
func (r *Redis) Configure(settings PoolSettings)
func (*Redis) Execute ¶
Generic method to execute any redis call Gets a client from pool, executes a cmd, puts conn back in pool
func (*Redis) GetClient ¶
Gets a connection from pool and converts to RedisConn type If all the connections are in use, timeout the present request after a minute
type RedisConn ¶
Wrapping redigo redis connection
Pool expects a Object which defines Close() and doesn't return anything, but redigo.Redis#Close() returns error, hence this wrapper around redis.Conn
type ResourcePool ¶
type ResourcePool struct {
// contains filtered or unexported fields
}
Wraps pool
func NewPool ¶
func NewPool(connect dialAndConnect, instance interface{}, settings PoolSettings) *ResourcePool
- Creats an instance of pool Params: connect: A callback which creates a connection to datastore instace: An instance of backend(redis instance) settings: configurations needed to create a pool
func (*ResourcePool) PutConn ¶
func (rp *ResourcePool) PutConn(conn pools.Resource)
Puts a connection back in pool
func (*ResourcePool) StatsJSON ¶
func (rp *ResourcePool) StatsJSON() string