From 182d21c5fd9236d2ed312c776e92fe2cc91c10b9 Mon Sep 17 00:00:00 2001 From: bryanqiu Date: Fri, 21 Jun 2024 17:44:05 +0800 Subject: [PATCH] featrue: NewPool --- redis.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/redis.go b/redis.go index 5189040..800028f 100644 --- a/redis.go +++ b/redis.go @@ -8,4 +8,14 @@ import ( type Config = sentinel.Config var NewPool = redis.NewPool +var NewRedisPool = redis.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") +}