wip: feat: implemented cache

This commit is contained in:
Jun Kurihara 2023-12-12 22:50:24 +09:00
commit bd29c9dc1d
No known key found for this signature in database
GPG key ID: 48ADFD173ED22B03
4 changed files with 113 additions and 23 deletions

View file

@ -47,12 +47,12 @@ where
{
let mut synth_req = None;
if self.cache.is_some() {
// TODO: try reading from cache
// if let Some(cached_response) = self.cache.as_ref().unwrap().get(&req).await {
// // if found, return it as response.
// info!("Cache hit - Return from cache");
// return Ok(cached_response);
// };
// try reading from cache
if let Some(cached_response) = self.cache.as_ref().unwrap().get(&req).await {
// if found, return it as response.
info!("Cache hit - Return from cache");
return Ok(cached_response);
};
// Synthetic request copy used just for caching (cannot clone request object...)
synth_req = Some(build_synth_req_for_cache(&req));