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