Struct ccache::slru::SLRU[][src]

pub struct SLRU<'a, K, V, Umeta, HB> where
    K: Hash,
    V: Val,
    Umeta: Meta<V>,
    HB: BuildHasher + Default
{ /* fields omitted */ }

SLRU implementation

SLRU is a Segmented LRU it consists of two LRU:

  • probation LRU: for items that have been just added
  • protected LRU: items that were in the probation LRU and received a HIT

W-TinyLFU specifies an 20-80 split, with 80% for the probation LRU You can define your own slit here

Implementations

impl<'a, K: Hash, V: Val, Umeta: Meta<V>, HB: BuildHasher + Default> SLRU<'a, K, V, Umeta, HB>[src]

pub fn new(
    probation_entries: usize,
    protected_entries: usize,
    extra_hashmap_capacity: usize,
    hash_builder: HB
) -> Self
[src]

new SLRU, with custom number of entries for the probatory and protected splits

pub fn insert(&mut self, key: K, val: V) -> InsertResult<(K, V, Umeta)>[src]

insert a new element. Can return a clash

pub fn insert_with_meta(
    &mut self,
    key: K,
    val: V,
    user_data: Umeta
) -> InsertResult<(K, V, Umeta)>
[src]

insert a new element, but with metadata

pub fn remove(&mut self, key: &K) -> Option<(V, Umeta)>[src]

remove an element

pub fn clear(&mut self)[src]

clear out all the SLRU

pub fn get(&mut self, key: &K) -> Option<(&V, &Umeta)>[src]

Get references to the element’s data

pub fn get_mut(&mut self, key: &K) -> Option<(&mut V, &mut Umeta)>[src]

get a mutable reference to the element’s data

Auto Trait Implementations

impl<'a, K, V, Umeta, HB> !RefUnwindSafe for SLRU<'a, K, V, Umeta, HB>

impl<'a, K, V, Umeta, HB> !Send for SLRU<'a, K, V, Umeta, HB>

impl<'a, K, V, Umeta, HB> !Sync for SLRU<'a, K, V, Umeta, HB>

impl<'a, K, V, Umeta, HB> Unpin for SLRU<'a, K, V, Umeta, HB> where
    HB: Unpin,
    K: Unpin,
    Umeta: Unpin,
    V: Unpin

impl<'a, K, V, Umeta, HB> !UnwindSafe for SLRU<'a, K, V, Umeta, HB>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,