gateway/external/redis/redis.go
crusader 30fe3d0fdb ing
2018-04-12 18:57:42 +09:00

49 lines
817 B
Go

package redis
import (
"git.loafle.net/commons/logging-go"
ocec "git.loafle.net/overflow/commons-go/external/config"
"github.com/gomodule/redigo/redis"
)
var Pool *redis.Pool
func InitPackage(config *ocec.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 *ocec.Redis) {
if nil == config {
return
}
}
func StopPackage(config *ocec.Redis) {
if nil == config {
return
}
}
func DestroyPackage(config *ocec.Redis) {
if nil == config {
return
}
Pool.Close()
}