From 576807b94ee8b22b40677efda6014a9daa278d7a Mon Sep 17 00:00:00 2001 From: bryanqiu Date: Fri, 28 Jun 2024 18:25:26 +0800 Subject: [PATCH] dev --- redis.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/redis.go b/redis.go index 5189040..20808a7 100644 --- a/redis.go +++ b/redis.go @@ -1,11 +1,25 @@ package redis import ( + redigo "github.com/gomodule/redigo/redis" "qoobing.com/gomod/redis/redis" "qoobing.com/gomod/redis/sentinel" ) -type Config = sentinel.Config +type ( + Conn = redigo.Conn + Pool = redigo.Pool + Config = sentinel.Config +) -var NewPool = redis.NewPool +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") +}