mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-10 23:47:29 +00:00
fix: 添加缓存表定时清理任务,修复 cache_link_info 无限增长
- CacheManager 添加 cleanupExpiredCache() 方法删除过期缓存记录 - PostExecVerticle 注册每小时执行一次的定时清理任务 - 原实现只有读时惰性检查过期,过期记录永远不会被删除,长期运行后数据库持续膨胀
This commit is contained in:
@@ -46,7 +46,7 @@ public class PostExecVerticle extends AbstractVerticle {
|
||||
return;
|
||||
}
|
||||
LOGGER.info("PostExecVerticle 开始执行...");
|
||||
|
||||
|
||||
if (appRunImplementations != null && !appRunImplementations.isEmpty()) {
|
||||
appRunImplementations.forEach(appRun -> {
|
||||
try {
|
||||
@@ -61,7 +61,17 @@ public class PostExecVerticle extends AbstractVerticle {
|
||||
} else {
|
||||
LOGGER.info("未找到 AppRun 接口的实现类");
|
||||
}
|
||||
|
||||
|
||||
// 注册定时清理过期缓存任务(每小时执行一次)
|
||||
vertx.setPeriodic(3600_000, 3600_000, id -> {
|
||||
try {
|
||||
cn.qaiu.lz.common.cache.CacheManager cacheManager = new cn.qaiu.lz.common.cache.CacheManager();
|
||||
cacheManager.cleanupExpiredCache();
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug("定时清理缓存任务跳过(数据库可能未就绪)", e);
|
||||
}
|
||||
});
|
||||
|
||||
LOGGER.info("PostExecVerticle 执行完成");
|
||||
startPromise.complete();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user