Skip to content

Commit

Permalink
fix: cache lookup now continues when cache lock acquisition fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Jotape24 committed Jan 28, 2025
1 parent 16d230b commit 685b045
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/async_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,16 @@ impl AsyncResolver {
// Search in cache only if its available
if self.config.is_cache_enabled() {
let lock_result = self.cache.lock();
match lock_result {
Ok(cache) => {
if let Some(cache_lookup) = cache.clone().get(query.clone()){
let new_lookup_response = LookupResponse::new(cache_lookup.clone(), cache_lookup.to_bytes());
return Ok(new_lookup_response);
}
}
Err(err) => {eprintln!("Error acquiring cache lock: {}", err);}
}
/*
let cache = match lock_result {
Ok(val) => val,
Err(_) => Err(ClientError::Message("Error getting cache"))?, // FIXME: it shouldn't
Expand All @@ -259,6 +269,7 @@ impl AsyncResolver {
return Ok(new_lookup_response);
}
*/
}

let mut lookup_strategy = LookupStrategy::new(query, self.config.clone());
Expand Down

0 comments on commit 685b045

Please sign in to comment.