26 lines
521 B
Go
26 lines
521 B
Go
|
package redis
|
||
|
|
||
|
import (
|
||
|
redigo "github.com/gomodule/redigo/redis"
|
||
|
"qoobing.com/gomod/redis/redis"
|
||
|
"qoobing.com/gomod/redis/sentinel"
|
||
|
)
|
||
|
|
||
|
type (
|
||
|
Conn = redigo.Conn
|
||
|
Pool = redigo.Pool
|
||
|
Config = sentinel.Config
|
||
|
)
|
||
|
|
||
|
var NewRedisPool = redis.NewPool
|
||
|
var NewSentinelPool = sentinel.NewPool
|
||
|
|
||
|
func NewPool(cfg Config) *redigo.Pool {
|
||
|
if cfg.Master != "" {
|
||
|
return NewRedisPool(cfg)
|
||
|
} else if cfg.MasterName != "" {
|
||
|
return NewSentinelPool(cfg)
|
||
|
}
|
||
|
panic("invalid config: Master & MasterName are both empty")
|
||
|
}
|