external-go/redis/redis.go

49 lines
817 B
Go
Raw Normal View History

2018-05-11 07:46:06 +00:00
package redis
import (
"git.loafle.net/commons/logging-go"
occe "git.loafle.net/overflow/commons-go/config/external"
"github.com/gomodule/redigo/redis"
)
var Pool *redis.Pool
func InitPackage(config *occe.Redis) {
if nil == config {
return
}
Pool = &redis.Pool{
MaxIdle: 1,
MaxActive: 3,
IdleTimeout: 240,
Wait: true,
MaxConnLifetime: 1,
Dial: func() (redis.Conn, error) {
return redis.Dial(config.Network, config.Address)
},
}
logging.Logger().Infof("Redis: initialized [%s:%s]", config.Network, config.Address)
}
func StartPackage(config *occe.Redis) {
if nil == config {
return
}
}
func StopPackage(config *occe.Redis) {
if nil == config {
return
}
}
func DestroyPackage(config *occe.Redis) {
if nil == config {
return
}
Pool.Close()
}