update
This commit is contained in:
21
src/main.rs
21
src/main.rs
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user