refactor(internal): 优化 OSS 预签名 URL 缓存刷新任务和英雄数据缓存逻辑

- 注释掉 OSS预签名 URL 缓存刷新任务的定时执行代码
- 在 hero/hero.go 中增加对 Redis缓存和英雄数据集的非空校验
- 修改 OSS预签名 URL 生成逻辑,自动替换为 CDN 域名
This commit is contained in:
hu xiaotong
2025-07-17 16:11:36 +08:00
parent 7b7f8c31d7
commit 8ab1379cae
4 changed files with 19 additions and 20 deletions

View File

@@ -174,11 +174,11 @@ func (l *Logic) registerDefaultJobs(ctx context.Context) error {
}
// 每30分钟执行一次OSS预签名URL缓存刷新任务
if err := l.AddJob(ctx, "oss_presignurl_refresh", "0 0/30 * * * *", func() {
l.refreshOssPresignUrlCacheJob(ctx)
}); err != nil {
return err
}
//if err := l.AddJob(ctx, "oss_presignurl_refresh", "0 0/30 * * * *", func() {
// l.refreshOssPresignUrlCacheJob(ctx)
//}); err != nil {
// return err
//}
return nil
}

View File

@@ -130,6 +130,12 @@ func (l *Logic) GetHeroDetailByCode(ctx context.Context, code string) (*v1.HeroD
if err != nil {
return nil, err
}
if util.RedisCache == nil {
panic("util.RedisCache is nil")
}
if fribbleHeroSet == nil {
panic("fribbleHeroSet is nil")
}
// 写入 Redis 缓存1小时
util.RedisCache.Set(ctx, cacheKey, fribbleHeroSet.JsonContent, 0)
}