gateway/external/redis/redis.go

49 lines
817 B
Go
Raw Normal View History

2018-04-09 11:37:54 +00:00
package redis
import (
2018-04-10 05:54:45 +00:00
"git.loafle.net/commons/logging-go"
2018-04-12 09:57:42 +00:00
ocec "git.loafle.net/overflow/commons-go/external/config"
2018-04-09 11:37:54 +00:00
"github.com/gomodule/redigo/redis"
)
var Pool *redis.Pool
2018-04-12 09:57:42 +00:00
func InitPackage(config *ocec.Redis) {
2018-04-10 05:21:48 +00: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 05:29:17 +00:00
return redis.Dial(config.Network, config.Address)
2018-04-10 05:21:48 +00:00
},
}
2018-04-10 05:54:45 +00:00
logging.Logger().Infof("Redis: initialized [%s:%s]", config.Network, config.Address)
2018-04-10 05:21:48 +00:00
}
2018-04-12 09:57:42 +00:00
func StartPackage(config *ocec.Redis) {
2018-04-10 05:21:48 +00:00
if nil == config {
return
}
2018-04-09 11:37:54 +00:00
}
2018-04-12 09:57:42 +00:00
func StopPackage(config *ocec.Redis) {
2018-04-10 05:21:48 +00:00
if nil == config {
return
}
}
2018-04-12 09:57:42 +00:00
func DestroyPackage(config *ocec.Redis) {
2018-04-10 05:21:48 +00:00
if nil == config {
return
}
2018-04-09 11:37:54 +00:00
Pool.Close()
}