pub struct RetentionPolicy<K, V>{
pub score: Arc<dyn Fn(&K, &V) -> f64 + Send + Sync>,
pub archive_threshold: Option<f64>,
pub max_size: Option<usize>,
pub on_archive: Option<Arc<dyn Fn(&K, &V, f64) + Send + Sync>>,
}Expand description
Score-based retention policy for ReactiveMap.
After every mutation, entries are scored and those below archive_threshold
(or exceeding max_size by ascending score) are archived (deleted).
Mutually exclusive with top-level max_size (LRU).
Fields§
§score: Arc<dyn Fn(&K, &V) -> f64 + Send + Sync>Score function — higher is kept.
archive_threshold: Option<f64>Entries scoring below this threshold are archived.
max_size: Option<usize>Maximum number of live entries. Lowest-scored entries archived first.
on_archive: Option<Arc<dyn Fn(&K, &V, f64) + Send + Sync>>Called for each archived entry.
Auto Trait Implementations§
impl<K, V> Freeze for RetentionPolicy<K, V>
impl<K, V> !RefUnwindSafe for RetentionPolicy<K, V>
impl<K, V> Send for RetentionPolicy<K, V>
impl<K, V> Sync for RetentionPolicy<K, V>
impl<K, V> Unpin for RetentionPolicy<K, V>
impl<K, V> UnsafeUnpin for RetentionPolicy<K, V>
impl<K, V> !UnwindSafe for RetentionPolicy<K, V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more