49 lines
828 B
Go
Raw Normal View History

2018-04-09 20:37:54 +09:00
package redis
import (
2018-04-10 14:54:45 +09:00
"git.loafle.net/commons/logging-go"
2018-04-10 14:21:48 +09:00
occer "git.loafle.net/overflow/commons-go/config/external/redis"
2018-04-09 20:37:54 +09:00
"github.com/gomodule/redigo/redis"
)
var Pool *redis.Pool
2018-04-10 14:29:17 +09:00
func InitPackage(config *occer.Redis) {
2018-04-10 14:21:48 +09:00
if nil == config {
return
}
Pool = &redis.Pool{
MaxIdle: 1,
MaxActive: 3,
IdleTimeout: 240,
Wait: true,
MaxConnLifetime: 1,
Dial: func() (redis.Conn, error) {
2018-04-10 14:29:17 +09:00
return redis.Dial(config.Network, config.Address)
2018-04-10 14:21:48 +09:00
},
}
2018-04-10 14:54:45 +09:00
logging.Logger().Infof("Redis: initialized [%s:%s]", config.Network, config.Address)
2018-04-10 14:21:48 +09:00
}
2018-04-10 14:29:17 +09:00
func StartPackage(config *occer.Redis) {
2018-04-10 14:21:48 +09:00
if nil == config {
return
}
2018-04-09 20:37:54 +09:00
}
2018-04-10 14:29:17 +09:00
func StopPackage(config *occer.Redis) {
2018-04-10 14:21:48 +09:00
if nil == config {
return
}
}
2018-04-10 14:29:17 +09:00
func DestroyPackage(config *occer.Redis) {
2018-04-10 14:21:48 +09:00
if nil == config {
return
}
2018-04-09 20:37:54 +09:00
Pool.Close()
}