From a1b42b9ccdbcfabdafc7921c90a861f7e29df242 Mon Sep 17 00:00:00 2001 From: zerosaturation Date: Thu, 14 May 2026 17:33:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=9D=E5=A7=8B=E5=8C=96=20Redis=20?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- backend/gateway/main.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backend/gateway/main.go b/backend/gateway/main.go index bba3b26..f4ff7e1 100644 --- a/backend/gateway/main.go +++ b/backend/gateway/main.go @@ -11,6 +11,7 @@ import ( "github.com/gin-gonic/gin" "github.com/topfans/backend/gateway/config" "github.com/topfans/backend/gateway/router" + "github.com/topfans/backend/pkg/database" "github.com/topfans/backend/pkg/logger" "go.uber.org/zap" @@ -66,6 +67,19 @@ func main() { // 3. 设置 Gin 模式 gin.SetMode(cfg.Server.Mode) + // 3.5 初始化 Redis + logger.Logger.Info("Connecting to Redis...") + if err := database.InitRedis(database.RedisConfig{ + Host: cfg.Redis.Host, + Port: cfg.Redis.Port, + Password: cfg.Redis.Password, + DB: cfg.Redis.DB, + }); err != nil { + logger.Logger.Fatal("Failed to connect to Redis", zap.Error(err)) + } + logger.Logger.Info("Redis connected successfully") + defer database.CloseRedis() + // 4. 初始化 Dubbo Clients logger.Logger.Info("Connecting to Dubbo services...")