49 lines
817 B
Go
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()
|
|
}
|