perf(cache): 三层缓存框架补强

- 新增 cache-framework skill,规范 RAM→Redis→DB 读路径、失效与 pub/sub
- 上传元数据 Otter+Redis 缓存与多节点失效;Auth Source 缓存与 pub/sub
- ListSystemConfigsByKeys 补 Redis 层;上传统计单事务;登录/Token 缓存预热
- cleanup 任务补 upload meta 失效钩子
This commit is contained in:
ryan
2026-06-20 10:17:50 +08:00
parent 8c872f9b32
commit cdac1f8a45
23 changed files with 1511 additions and 20 deletions
+3
View File
@@ -362,6 +362,7 @@ func createAccessTokenLogic(ctx context.Context, record *model.AccessToken) erro
if err := db.DB(ctx).Create(record).Error; err != nil {
return errors.New("创建令牌失败,请稍后再试")
}
oauth.SetCachedToken(ctx, record.TokenHash, record)
return nil
}
@@ -405,6 +406,8 @@ func rotateAccessTokenLogic(ctx context.Context, id, userID uint64) (string, *mo
return "", nil, errors.New("轮换令牌失败,请稍后再试")
}
oauth.SetCachedToken(ctx, tokenRecord.TokenHash, &tokenRecord)
return newTokenStr, &tokenRecord, nil
}
+2
View File
@@ -168,6 +168,8 @@ func Login(c *gin.Context) {
return
}
oauth.SetCachedUser(ctx, user.ID, user)
logger.InfoF(ctx, "[LoginAudit] successful login for user: %s, ID: %d, IP: %s", user.Username, user.ID, c.ClientIP())
listener.EmitAdminLoggedIn(ctx, user, c.ClientIP())