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
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F

View File

@ -306,9 +306,10 @@ impl<K: Eq + Hash + Clone, V> ArcCache<K, V> {
return evicted;
}
// TODO not sure that I understand
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;
}
@ -335,7 +336,9 @@ impl<K: Eq + Hash + Clone, V> ArcCache<K, V> {
};
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);
if let Some(evicted_entry) = self.frequent_set.push(key, value) {
evicted.push(evicted_entry);