pub trait Coster<V>: Send + Sync + 'static {
    fn cost(&self, val: &V) -> i64;
}
Expand description

Cost is a trait you can pass to the CacheBuilder in order to evaluate item cost at runtime, and only for the insert calls that aren’t dropped (this is useful if calculating item cost is particularly expensive, and you don’t want to waste time on items that will be dropped anyways).

To signal to Stretto that you’d like to use this Coster trait:

  1. Set the Coster field to your own Coster implementation.
  2. When calling insert for new items or item updates, use a cost of 0.

Required methods

cost evaluates a value and outputs a corresponding cost. This function is ran after insert is called for a new item or an item update with a cost param of 0.

Implementors