xonx4l commented on code in PR #19140:
URL: https://github.com/apache/datafusion/pull/19140#discussion_r2606978193
##########
datafusion/execution/src/cache/list_files_cache.rs:
##########
@@ -142,46 +173,44 @@ impl DefaultListFilesCacheState {
}
/// Returns the respective entry from the cache, if it exists and the
entry has not expired.
- /// If the entry exists it becomes the most recently used. If the entry
has expired it is
- /// removed from the cache
- fn get(&mut self, key: &Path) -> Option<Arc<Vec<ObjectMeta>>> {
+ /// Takes `now` explicitly to determine expiration.
+ fn get(&mut self, key: &Path, now: Instant) ->
Option<Arc<Vec<ObjectMeta>>> {
let entry = self.lru_queue.get(key)?;
match entry.expires {
- Some(exp) if Instant::now() > exp => {
+ Some(exp) if now > exp => {
self.remove(key);
None
}
_ => Some(Arc::clone(&entry.metas)),
}
}
- /// Checks if the respective entry is currently cached. If the entry has
expired it is removed
- /// from the cache.
- /// The LRU queue is not updated.
- fn contains_key(&mut self, k: &Path) -> bool {
+ /// Checks if the respective entry is currently cached.
+ /// Takes `now` explicitly to determine expiration.
+ fn contains_key(&mut self, k: &Path, now: Instant) -> bool {
let Some(entry) = self.lru_queue.peek(k) else {
return false;
};
match entry.expires {
- Some(exp) if Instant::now() > exp => {
+ Some(exp) if now > exp => {
self.remove(k);
false
}
_ => true,
}
}
- /// Adds a new key-value pair to cache, meaning LRU entries might be
evicted if required.
- /// If the key is already in the cache, the previous entry is returned.
- /// If the size of the entry is greater than the `memory_limit`, the value
is not inserted.
+ /// Adds a new key-value pair to cache.
+ /// Takes `now` explicitly to determine expiration.
Review Comment:
Yeah the suggested comment looks good to me . Will update that. Thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]