feat: annealing for hot score & clean cache

This commit is contained in:
2022-03-26 01:04:22 +08:00
parent 38bacc1ee0
commit 59714bfbef
7 changed files with 74 additions and 23 deletions

View File

@@ -29,18 +29,18 @@ pub async fn delete(
p.change_n_comments(&db, -1).await?;
p.change_hot_score(&db, -1).await?;
p.refresh_cache(&rconn, false).await;
p.clear_comments_cache(&rconn).await;
}
"pid" => {
p = Post::get(&db, &rconn, di.id).await?;
p.soft_delete(&user, &db).await?;
// 如果是删除需要也从0号缓存队列中去掉
p.refresh_cache(&rconn, true).await;
}
_ => return Err(APIError::PcError(NotAllowed)),
}
// 如果是删除需要也从0号缓存队列中去掉
p.refresh_cache(&rconn, true).await;
Ok(json!({
"code": 0
}))

View File

@@ -164,7 +164,7 @@ pub async fn edit_cw(cwi: Form<CwInput>, user: CurrentUser, db: Db, rconn: RdsCo
}
p.check_permission(&user, "w")?;
p.update_cw(&db, cwi.cw.to_string()).await?;
p.refresh_cache(&rconn, false);
p.refresh_cache(&rconn, false).await;
Ok(json!({"code": 0}))
}