feat: totally updated cache structure using lru crate instead of moka (i.e., using simpler crate)
This commit is contained in:
parent
2477c6bf1b
commit
07d3accb91
10 changed files with 157 additions and 132 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use super::cache::RpxyCache;
|
||||
use super::cache::{get_policy_if_cacheable, RpxyCache};
|
||||
use crate::{error::RpxyError, globals::Globals, log::*, CryptoSource};
|
||||
use async_trait::async_trait;
|
||||
use bytes::Buf;
|
||||
|
|
@ -55,7 +55,7 @@ where
|
|||
if self.cache.is_some() {
|
||||
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");
|
||||
info!("Cache hit - Return from cache");
|
||||
return Ok(cached_response);
|
||||
};
|
||||
|
||||
|
|
@ -76,13 +76,9 @@ where
|
|||
}
|
||||
|
||||
// check cacheability and store it if cacheable
|
||||
let Ok(Some(cache_policy)) = self
|
||||
.cache
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.is_cacheable(synth_req.as_ref(), res.as_ref().ok()) else {
|
||||
return res;
|
||||
};
|
||||
let Ok(Some(cache_policy)) = get_policy_if_cacheable(synth_req.as_ref(), res.as_ref().ok()) else {
|
||||
return res;
|
||||
};
|
||||
let (parts, body) = res.unwrap().into_parts();
|
||||
// TODO: Inefficient?
|
||||
let Ok(mut bytes) = hyper::body::aggregate(body).await else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue