Skip to main content

Lifecycle

Trait Lifecycle 

Source
pub trait Lifecycle<K, V> {
    // Provided methods
    fn on_eviction(&mut self, _key: K, _value: V) { ... }
    fn evaluate(&self, _key: &K, _value: &V) -> EntryStatus { ... }
}

Provided Methods§

Source

fn on_eviction(&mut self, _key: K, _value: V)

Called when an entry has been evicted from the cache. Receives ownership of the key and value so they can be forwarded or dropped.

Source

fn evaluate(&self, _key: &K, _value: &V) -> EntryStatus

Inspect an existing entry and decide whether it should remain in the cache. Called as the sieve hand passes over entries during Cache::put.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<K, V> Lifecycle<K, V> for DefaultLifecycle

Source§

impl<K, V, L> Lifecycle<K, V> for TtlLifecycle<L>
where V: Ttl, L: Lifecycle<K, V>,