Documentation
¶
Index ¶
- Variables
- func CreateMemcacheConnection(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
- func (m *Memcache) Execute(cmd string, args ...interface{}) (interface{}, error)
- func (m *Memcache) Expire(key string, duration int) bool
- func (m *Memcache) Get(key string) string
- func (m *Memcache) GetClient() *MemConn
- func (m *Memcache) MGet(keys ...interface{}) []string
- func (m *Memcache) MSet(mapOfKeyVal map[string]interface{}) bool
- func (m *Memcache) PutClient(c *MemConn)
- func (m *Memcache) Set(key string, value interface{}) bool
- func (m *Memcache) SetDefaults()
- func (m *Memcache) Setex(key string, duration int, val interface{}) bool
- type PoolSettings
- type Redis
- func (r *Redis) Configure(settings PoolSettings)
- func (r *Redis) Delete(keys ...interface{}) int
- func (r *Redis) Execute(cmd string, args ...interface{}) (interface{}, error)
- func (r *Redis) Expire(key string, duration int) bool
- func (r *Redis) Get(key string) string
- func (r *Redis) GetClient() (*RedisConn, error)
- func (r *Redis) MGet(keys ...interface{}) []string
- func (r *Redis) MSet(mapOfKeyVal map[string]interface{}) bool
- func (r *Redis) PutClient(c *RedisConn)
- func (r *Redis) Set(key string, value interface{}) bool
- func (r *Redis) SetDefaults()
- func (r *Redis) Setex(key string, duration int, val interface{}) bool
- type RedisConn
- type ResourcePool
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultMemcacheIpAndHost = []string{"localhost:11211"}
View Source
var DefaultRedisConfig = []string{"localhost:6379"}
default host:port to connect
View Source
var MemcachePoolSize = 10
View Source
var RedisPoolSize = 10
default pool size
Functions ¶
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()
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
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
Click to show internal directories.
Click to hide internal directories.