2018-04-09 11:37:54 +00:00
|
|
|
package redis
|
|
|
|
|
|
|
|
import (
|
2018-04-10 05:21:48 +00:00
|
|
|
occer "git.loafle.net/overflow/commons-go/config/external/redis"
|
2018-04-09 11:37:54 +00:00
|
|
|
"github.com/gomodule/redigo/redis"
|
|
|
|
)
|
|
|
|
|
|
|
|
var Pool *redis.Pool
|
|
|
|
|
2018-04-10 05:21:48 +00:00
|
|
|
func InitPackage(config *occer.RedisConfig) {
|
|
|
|
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("tcp", "192.168.1.50:6379")
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func StartPackage(config *occer.RedisConfig) {
|
|
|
|
if nil == config {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-04-09 11:37:54 +00:00
|
|
|
}
|
|
|
|
|
2018-04-10 05:21:48 +00:00
|
|
|
func StopPackage(config *occer.RedisConfig) {
|
|
|
|
if nil == config {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func DestroyPackage(config *occer.RedisConfig) {
|
|
|
|
if nil == config {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-04-09 11:37:54 +00:00
|
|
|
Pool.Close()
|
|
|
|
}
|