Fix one and for all the ARC cache

This commit is contained in:
Clément Renault
2024-07-21 22:32:14 +02:00
parent b03ec3f603
commit 2b7b18fb5f

View File

@@ -306,9 +306,10 @@ impl<K: Eq + Hash + Clone, V> ArcCache<K, V> {
return evicted; return evicted;
} }
// TODO not sure that I understand
if self.frequent_set.contains(&key) { if self.frequent_set.contains(&key) {
self.frequent_set.get(&key); if let Some(evicted_entry) = self.frequent_set.push(key, value) {
evicted.push(evicted_entry);
}
return evicted; return evicted;
} }
@@ -335,7 +336,9 @@ impl<K: Eq + Hash + Clone, V> ArcCache<K, V> {
}; };
self.p = (self.p + delta).min(self.capacity.get()); self.p = (self.p + delta).min(self.capacity.get());
self.replace(&key); if let Some(evicted_entry) = self.replace(&key) {
evicted.push(evicted_entry);
}
self.recent_evicted.pop(&key); self.recent_evicted.pop(&key);
if let Some(evicted_entry) = self.frequent_set.push(key, value) { if let Some(evicted_entry) = self.frequent_set.push(key, value) {
evicted.push(evicted_entry); evicted.push(evicted_entry);