deprecated_overflow_gateway.../external/redis/pool.go

43 lines
865 B
Go
Raw Permalink Normal View History

2017-11-09 09:14:57 +00:00
package redis
import (
"fmt"
"git.loafle.net/overflow/overflow_gateway_app/conf"
"git.loafle.net/commons_go/logging"
crp "git.loafle.net/commons_go/redis_pool"
"github.com/garyburd/redigo/redis"
)
var RedisPool crp.Pool
func ExternalInit() {
ph := &redisPoolHandlers{}
ph.MaxCapacity = conf.Config.Redis.Pool.MaxCapacity
ph.MaxIdle = conf.Config.Redis.Pool.MaxIdle
ph.IdleTimeout = conf.Config.Redis.Pool.IdleTimeout
ph.Wait = conf.Config.Redis.Pool.Wait
RedisPool = crp.New(ph)
if err := RedisPool.Start(); nil != err {
logging.Logger().Panic(fmt.Sprintf("App: %v", err))
return
}
}
func ExternalDestroy() {
if nil != RedisPool {
RedisPool.Stop()
}
}
type redisPoolHandlers struct {
crp.PoolHandlers
}
func (ph *redisPoolHandlers) Dial() (redis.Conn, error) {
return redis.Dial(conf.Config.Redis.Network, conf.Config.Redis.Addr)
}