diff --git a/rpxy-lib/Cargo.toml b/rpxy-lib/Cargo.toml index a859131..9cd6265 100644 --- a/rpxy-lib/Cargo.toml +++ b/rpxy-lib/Cargo.toml @@ -75,7 +75,7 @@ s2n-quic-rustls = { path = "../submodules/s2n-quic/quic/s2n-quic-rustls/", optio # cache http-cache-semantics = { path = "../submodules/rusty-http-cache-semantics/" } -moka = { version = "0.11.3", features = ["future"] } +moka = { version = "0.11.3", features = ["future", "sync"] } # cookie handling for sticky cookie chrono = { version = "0.4.26", default-features = false, features = [ diff --git a/rpxy-lib/src/handler/cache.rs b/rpxy-lib/src/handler/cache.rs index 6b672d3..8bc14f8 100644 --- a/rpxy-lib/src/handler/cache.rs +++ b/rpxy-lib/src/handler/cache.rs @@ -106,11 +106,12 @@ impl RpxyCache { }; let Ok(mut file) = File::open(&filepath.clone()).await else { - warn!("Cache file doesn't exist. Remove pointer cache."); - let my_cache = self.inner.clone(); - self.runtime_handle.spawn(async move { - my_cache.invalidate(&moka_key).await; - }); + warn!("Cache file object doesn't exist. Remove cache entry."); + self.inner.invalidate(&moka_key).await; + // let my_cache = self.inner.clone(); + // self.runtime_handle.spawn(async move { + // my_cache.invalidate(&moka_key).await; + // }); return None; }; let (body_sender, res_body) = Body::channel(); @@ -134,11 +135,12 @@ impl RpxyCache { } else { // Evict stale cache entry here debug!("Evict stale cache entry and file object: {moka_key}"); - let my_cache = self.inner.clone(); - self.runtime_handle.spawn(async move { - // eviction listener will be activated during invalidation. - my_cache.invalidate(&moka_key).await; - }); + self.inner.invalidate(&moka_key).await; + // let my_cache = self.inner.clone(); + // self.runtime_handle.spawn(async move { + // eviction listener will be activated during invalidation. + // my_cache.invalidate(&moka_key).await; + // }); None } } diff --git a/rpxy-lib/src/handler/forwarder.rs b/rpxy-lib/src/handler/forwarder.rs index fab1342..713ba06 100644 --- a/rpxy-lib/src/handler/forwarder.rs +++ b/rpxy-lib/src/handler/forwarder.rs @@ -53,7 +53,6 @@ where async fn request(&self, req: Request) -> Result, Self::Error> { let mut synth_req = None; if self.cache.is_some() { - debug!("Search cache first"); if let Some(cached_response) = self.cache.as_ref().unwrap().get(&req).await { // if found, return it as response. debug!("Cache hit - Return from cache");