diff --git a/Cargo.lock b/Cargo.lock index 50a1694..f7e31e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3297,8 +3297,6 @@ dependencies = [ [[package]] name = "salvo-proxy" version = "0.58.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29d90e485a13ecb0f0f4b27db0888d96b3899b3c6718c268a9350667e921577e" dependencies = [ "fastrand 2.0.0", "futures-util", @@ -3333,8 +3331,6 @@ dependencies = [ [[package]] name = "salvo_core" version = "0.58.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "661eabf006e4b5dde529a7a31dd875f82b9505d64ac82a517538729d9110941a" dependencies = [ "anyhow", "async-trait", @@ -3409,8 +3405,6 @@ dependencies = [ [[package]] name = "salvo_macros" version = "0.58.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d3886e7c3e07d17664800b7aa0015839759e231c29069dc101f7e351531bd1" dependencies = [ "cruet", "proc-macro-crate", diff --git a/Cargo.toml b/Cargo.toml index 6113109..cb5ef2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,9 +65,9 @@ rstest = "0.18.1" #[features] #test = [] -# [patch.crates-io] -# salvo-proxy = { path = "../salvo/crates/proxy" } -# salvo_core = { path = "../salvo/crates/core" } +[patch.crates-io] +salvo-proxy = { path = "../salvo/crates/proxy" } +salvo_core = { path = "../salvo/crates/core" } #salvo-cache = { path = "../salvo/crates/cache" } [profile.release] diff --git a/src/cache.rs b/src/cache.rs index 9b36656..8855140 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -54,8 +54,10 @@ pub enum Expiration { Never, /// Global TTL from the config Global, - /// Expires after a mint + /// Expires after a month Month, + /// Expires after a day + Day, } impl Expiration { @@ -66,6 +68,7 @@ impl Expiration { Expiration::Never => None, Expiration::Global => Some(Duration::from_secs(config.cache_ttl)), Expiration::Month => Some(Duration::from_secs(30 * 24 * 60 * 60)), + Expiration::Day => Some(Duration::from_secs(60 * 60 * 24)), } } } diff --git a/src/models.rs b/src/models.rs index 4284982..674dae7 100644 --- a/src/models.rs +++ b/src/models.rs @@ -1298,8 +1298,12 @@ impl MetaData { } } + let mut cache_expiry = crate::cache::Expiration::Month; + if image.is_none() { + cache_expiry = crate::cache::Expiration::Day; + } let _ = GLOBAL_CACHE - .insert(cache_key, image.clone(), crate::cache::Expiration::Month) + .insert(cache_key, image.clone(), cache_expiry) .await; image } diff --git a/src/proxy.rs b/src/proxy.rs index f731a68..5af5ff0 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -77,7 +77,6 @@ where res: &mut salvo::Response, ctrl: &mut FlowCtrl, ) { - // let mut reqq = RequestBuilder::new(req.uri_mut().to_string(), req.method_mut().clone()).build(); self.inner.handle(req, depot, res, ctrl).await; } }