feat: 实现 Redis 会话存储,支持内存/Redis 双模式自动切换
- 新增 go-redis/v9 依赖 - 新增 config.yaml redis 配置段 + RedisConfig 结构体 + REDIS_PASSWORD 环境变量覆盖 - 新增 common/redis.go Redis 客户端初始化 - 完整实现 session/redis_store.go,实现 Store 接口全部 7 个方法 - Redis TTL 自动过期,无须后台清理 goroutine - deps_core.go 根据 cfg.Redis.Enabled 自动选择 RedisStore/MemoryStore - router.go + main.go 透传 redisClient 参数
This commit is contained in:
@ -8,11 +8,12 @@ import (
|
||||
"metazone.cc/metalab/internal/repository"
|
||||
"metazone.cc/metalab/internal/service"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func buildDeps(db *gorm.DB, cfg *config.Config, siteSettings *config.SiteSettings) *dependencies {
|
||||
userRepo, sessionMgr, authService, _, authCtrl, avatarSvc, authMdw, adminController := buildDepsCore(db, cfg, siteSettings)
|
||||
func buildDeps(db *gorm.DB, cfg *config.Config, siteSettings *config.SiteSettings, redisClient *redis.Client) *dependencies {
|
||||
userRepo, sessionMgr, authService, _, authCtrl, avatarSvc, authMdw, adminController := buildDepsCore(db, cfg, siteSettings, redisClient)
|
||||
|
||||
auditRepo := repository.NewAuditRepo(db)
|
||||
notificationRepo := repository.NewNotificationRepo(db)
|
||||
|
||||
Reference in New Issue
Block a user