update code level
This commit is contained in:
11
src/main.rs
11
src/main.rs
@@ -54,7 +54,7 @@ async fn main() -> std::io::Result<()> {
|
||||
|
||||
// 初始化相册内存缓存
|
||||
let albums_cache = Arc::new(tokio::sync::RwLock::new(AlbumsCache::new()));
|
||||
|
||||
|
||||
// 初始加载相册数据到缓存
|
||||
let initial_cache = Arc::clone(&albums_cache);
|
||||
let initial_db = Arc::clone(&db);
|
||||
@@ -76,10 +76,10 @@ async fn main() -> std::io::Result<()> {
|
||||
let refresh_db = Arc::clone(&db);
|
||||
tokio::spawn(async move {
|
||||
let mut interval = interval(Duration::from_secs(30 * 60)); // 30分钟
|
||||
|
||||
|
||||
loop {
|
||||
interval.tick().await;
|
||||
|
||||
|
||||
match refresh_db.get_all_albums().await {
|
||||
Ok(albums) => {
|
||||
let mut cache = refresh_cache.write().await;
|
||||
@@ -131,10 +131,7 @@ async fn main() -> std::io::Result<()> {
|
||||
.route("/api/album/{id}", web::get().to(routes::get_album_detail))
|
||||
.route("/api/albums", web::post().to(routes::create_album))
|
||||
.route("/api/thumbnail/{id}", web::get().to(routes::get_thumbnail))
|
||||
.route(
|
||||
"/api/original/{id}",
|
||||
web::get().to(routes::get_original_image),
|
||||
)
|
||||
.route("/api/original/{id}", web::get().to(routes::get_original_image))
|
||||
// 收藏功能API路由
|
||||
.route("/api/favorites", web::get().to(routes::get_favorites))
|
||||
.route("/api/favorites/status/{id}", web::get().to(routes::check_favorite_status))
|
||||
|
||||
Reference in New Issue
Block a user