From bcb9f994ceb9c22841890a5b003c2a95fd7aa64b Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Mon, 25 Mar 2024 16:18:03 +0800 Subject: [PATCH] update --- app/cfg/init_cache.go | 2 +- app/utils/cache/redis.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/cfg/init_cache.go b/app/cfg/init_cache.go index 873657f..12c338c 100644 --- a/app/cfg/init_cache.go +++ b/app/cfg/init_cache.go @@ -5,5 +5,5 @@ import ( ) func InitCache() { - cache.NewRedis(RedisAddr) + cache.NewRedis(RedisAddr, RedisPassword) } diff --git a/app/utils/cache/redis.go b/app/utils/cache/redis.go index 3c4b914..71679c0 100644 --- a/app/utils/cache/redis.go +++ b/app/utils/cache/redis.go @@ -36,7 +36,7 @@ type Config struct { var pool *redigo.Pool var conf *Config -func NewRedis(addr string) { +func NewRedis(addr, pwd string) { if addr == "" { panic("\nredis connect string cannot be empty\n") } @@ -48,6 +48,7 @@ func NewRedis(addr string) { Wait: true, Dial: func() (redigo.Conn, error) { c, err := redigo.Dial("tcp", addr, + redigo.DialPassword(pwd), redigo.DialConnectTimeout(redisDialTTL), redigo.DialReadTimeout(redisReadTTL), redigo.DialWriteTimeout(redisWriteTTL),