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]
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]
probation_entries: usize,
protected_entries: usize,
extra_hashmap_capacity: usize,
hash_builder: HB
) -> Self
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]
&mut self,
key: K,
val: V,
user_data: Umeta
) -> InsertResult<(K, V, Umeta)>
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> !RefUnwindSafe 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> 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>
impl<'a, K, V, Umeta, HB> !UnwindSafe for SLRU<'a, K, V, Umeta, HB>