组用户功能修订
ci-userbase-service / build-and-push (push) Failing after 1m45s

This commit is contained in:
chenxing
2026-08-12 19:16:22 +08:00
parent f55c865ab1
commit a5ced786b4
28 changed files with 1488 additions and 202 deletions
@@ -0,0 +1,48 @@
package com.yunhai.userbase.task;
import com.yunhai.userbase.service.impl.SignKeyCacheService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* 签名密钥共享缓存的对账/同步定时任务。<br>
* <br>
* 每天凌晨 3:05 执行(让 {@link OperationLogCleanupTask} 的 3:00 先跑完,避免同一时间打库):
* <ol>
* <li>把 application_info 表全量同步到共享 Redis;</li>
* <li>清理 DB 已删除、但 Redis 残留的旧应用 key;</li>
* <li>清空本机 AppSecretProvider / LocalAppIdentityProvider 的本地密钥缓存,
* 避免长驻进程本地缓存和 DB 不一致。</li>
* </ol>
* <p>
* 注:应用日常新增/删除/重置密钥会通过
* {@link com.yunhai.userbase.service.impl.ApplicationInfoService} 的事务事件
* 实时触发 {@link SignKeyCacheService} 的 syncOne/removeOne,
* 本任务仅作为「每日对账兜底」,防止 Redis 故障或人工介入导致的偏差。
*/
@Component
public class SignKeyCacheDailyTask {
private static final Logger log = LoggerFactory.getLogger(SignKeyCacheDailyTask.class);
@Autowired
private SignKeyCacheService signKeyCacheService;
/**
* 每天凌晨 3:05 执行,错开 OperationLogCleanupTask 的 3:00。
*/
@Scheduled(cron = "0 5 3 * * ?")
@Async
public void syncAll() {
try {
int n = signKeyCacheService.refreshAll();
log.info("[SignKeyCache] daily sync-all done, synced apps={}", n);
} catch (Exception e) {
log.warn("[SignKeyCache] daily sync-all failed: {}", e.getMessage());
}
}
}