mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-11 07:57:28 +00:00
fix: 修复编译错误,core 模块不能依赖 web-service/parser/core-database
core 模块的 Deploy.java 和 PostExecVerticle.java 直接引用了上层模块的类, 导致编译失败(package does not exist)。 - Deploy.java: 移除对 JDBCPoolInit 和 JsParserExecutor 的显式调用, vertx.close() 会级联关闭 Vert.x 创建的资源 - PostExecVerticle.java: 移除缓存定时清理逻辑(不能引用 web-service 的 CacheManager) - CacheManager: 添加 registerPeriodicCleanup() 静态方法,通过 VertxHolder 注册定时任务 - CacheServiceImpl: static 块中调用 CacheManager.registerPeriodicCleanup(),服务加载时自动注册
This commit is contained in:
@@ -225,6 +225,26 @@ public class CacheManager {
|
||||
return promise.future();
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册定时清理过期缓存任务(每小时执行一次)
|
||||
* 应在应用启动后调用
|
||||
*/
|
||||
public static void registerPeriodicCleanup() {
|
||||
try {
|
||||
io.vertx.core.Vertx vertx = cn.qaiu.vx.core.util.VertxHolder.getVertxInstance();
|
||||
vertx.setPeriodic(3600_000, 3600_000, id -> {
|
||||
try {
|
||||
new CacheManager().cleanupExpiredCache();
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("定时清理缓存任务跳过(数据库可能未就绪)", e);
|
||||
}
|
||||
});
|
||||
LOGGER.info("缓存定时清理任务已注册(每小时执行)");
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("注册缓存定时清理任务失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Future<Map<String, Integer>> getShareKeyTotal(String shareKey) {
|
||||
String sql = """
|
||||
SELECT `share_key`, SUM(cache_hit_total) AS hit_total, SUM(api_parser_total) AS parser_total
|
||||
|
||||
@@ -29,6 +29,11 @@ public class CacheServiceImpl implements CacheService {
|
||||
|
||||
private final CacheManager cacheManager = new CacheManager();
|
||||
|
||||
static {
|
||||
// 服务类加载时注册缓存定时清理任务
|
||||
CacheManager.registerPeriodicCleanup();
|
||||
}
|
||||
|
||||
private Future<CacheLinkInfo> getAndSaveCachedShareLink(ParserCreate parserCreate) {
|
||||
|
||||
// 认证、域名相关(检查是否已经添加过参数,避免重复调用)
|
||||
|
||||
Reference in New Issue
Block a user