featrue: NewPool

This commit is contained in:
bryanqiu 2024-06-21 17:44:05 +08:00
parent ace40d5502
commit 182d21c5fd

View File

@ -8,4 +8,14 @@ import (
type Config = sentinel.Config type Config = sentinel.Config
var NewPool = redis.NewPool var NewPool = redis.NewPool
var NewRedisPool = redis.NewPool
var NewSentinelPool = sentinel.NewPool var NewSentinelPool = sentinel.NewPool
func NewPool(cfg Config) *redis.Pool {
if cfg.Master != "" {
return NewRedisPool(cfg)
} else if cfg.MasterName {
return NewSentinelPool(cfg)
}
panic("invalid config: Master & MasterName are both empty")
}