|
@@ -55,10 +55,13 @@ impl InMemoryCache {
|
|
let age = elapsed.num_seconds();
|
|
let age = elapsed.num_seconds();
|
|
// The cache entry is out of date, so we need to remove it.
|
|
// The cache entry is out of date, so we need to remove it.
|
|
if let Some(invalidate_after) = self.invalidate_after {
|
|
if let Some(invalidate_after) = self.invalidate_after {
|
|
- if elapsed.to_std().unwrap() > invalidate_after {
|
|
|
|
- tracing::trace!("memory cache out of date");
|
|
|
|
- memory_cache.pop(route);
|
|
|
|
- return Ok(None);
|
|
|
|
|
|
+ // If we can't convert to a std duration, the duration is negative and hasn't elapsed yet.
|
|
|
|
+ if let Ok(std_elapsed) = elapsed.to_std() {
|
|
|
|
+ if std_elapsed > invalidate_after {
|
|
|
|
+ tracing::trace!("memory cache out of date");
|
|
|
|
+ memory_cache.pop(route);
|
|
|
|
+ return Ok(None);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|