fix(auth): 修复用户注册和登录后缓存清理问题
Build docker and publish / build (20.15.1) (push) Successful in 6m43s

在用户注册、登录、修改订阅和删除订阅等操作后,添加清理服务器缓存的逻辑
同时修复电话重置密码验证码解析问题
This commit is contained in:
2025-11-01 09:31:38 -07:00
parent 49d3fc1c74
commit 01eab942fd
8 changed files with 82 additions and 5 deletions
+25
View File
@@ -14,6 +14,7 @@ type customServerLogicModel interface {
FilterNodeList(ctx context.Context, params *FilterNodeParams) (int64, []*Node, error)
ClearNodeCache(ctx context.Context, params *FilterNodeParams) error
CountNodesByIdsAndTags(ctx context.Context, nodeIds []int64, tags []string) (int64, error)
ClearServerAllCache(ctx context.Context) error
}
const (
@@ -172,6 +173,30 @@ func (m *customServerModel) ClearServerCache(ctx context.Context, serverId int64
return nil
}
func (m *customServerModel) ClearServerAllCache(ctx context.Context) error {
var cursor uint64
var keys []string
prefix := ServerConfigCacheKey + "*"
for {
scanKeys, newCursor, err := m.Cache.Scan(ctx, cursor, prefix, 999).Result()
if err != nil {
m.Logger.Error(ctx, fmt.Sprintf("ClearServerAllCache err:%v", err))
break
}
m.Logger.Info(ctx, fmt.Sprintf("ClearServerAllCache query keys:%v", scanKeys))
keys = append(keys, scanKeys...)
cursor = newCursor
if cursor == 0 {
break
}
}
if len(keys) > 0 {
m.Logger.Info(ctx, fmt.Sprintf("ClearServerAllCache keys:%v", keys))
return m.Cache.Del(ctx, keys...).Err()
}
return nil
}
// InSet 支持多值 OR 查询
func InSet(field string, values []string) func(db *gorm.DB) *gorm.DB {
return func(db *gorm.DB) *gorm.DB {