This commit is contained in:
lychang
2026-07-19 18:57:30 +08:00
parent 879598585b
commit 34fdb18919
11 changed files with 2267 additions and 1531 deletions

View File

@@ -72,6 +72,16 @@ async fn main() -> std::io::Result<()> {
} else {
info!("[后台任务] 所有相册已解析,无需处理");
}
// 解析完成后,执行一次人物合并
tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;
info!("[后台任务] 执行人物合并分析...");
let result = engine::person_merger::execute_merge(&db_parse).await;
if result.persons_merged > 0 {
info!("[后台任务] 人物合并完成:分析 {} 组,合并 {} 人", result.groups_analyzed, result.persons_merged);
} else {
info!("[后台任务] 无需要合并的人物");
}
});
// 相册内存缓存
@@ -93,13 +103,22 @@ async fn main() -> std::io::Result<()> {
}
});
// 定时刷新缓存(每30分钟)
// 定时任务(每30分钟):刷新缓存 + 人物合并
let refresh_cache = Arc::clone(&albums_cache);
let refresh_db = Arc::clone(&db);
tokio::spawn(async move {
let mut interval = interval(Duration::from_secs(30 * 60));
loop {
interval.tick().await;
// 1. 执行人物合并
info!("[定时任务] 执行人物合并分析...");
let result = engine::person_merger::execute_merge(&refresh_db).await;
if result.persons_merged > 0 {
info!("[定时任务] 人物合并完成:分析 {} 组,合并 {} 人", result.groups_analyzed, result.persons_merged);
}
// 2. 刷新缓存
match refresh_db.get_all_albums().await {
Ok(albums) => {
let mut cache = refresh_cache.write().await;