pub trait CacheCallback<V: Send + Sync>: Send + Sync + 'static {
    fn on_exit(&self, val: Option<V>);

    fn on_evict(&self, item: Item<V>) { ... }
fn on_reject(&self, item: Item<V>) { ... } }
Expand description

CacheCallback is for customize some extra operations on values when related event happens.

Required methods

on_exit is called whenever a value is removed from cache. This can be used to do manual memory deallocation. Would also be called on eviction and rejection of the value.

Provided methods

on_evict is called for every eviction and passes the hashed key, value, and cost to the function.

on_reject is called for every rejection done via the policy.

Implementors