Struct tlspuffin::tls::rustls::limited_cache::LimitedCache
source · Expand description
A HashMap-alike, which never gets larger than a specified capacity, and evicts the oldest insertion to maintain this.
The requested capacity may be rounded up by the underlying collections. This implementation uses all the allocated storage.
This is inefficient: it stores keys twice.
Fields§
§map: HashMap<K, V>
§oldest: VecDeque<K>
Implementations§
source§impl<K, V> LimitedCache<K, V>where
K: Eq + Hash + Clone + Debug,
impl<K, V> LimitedCache<K, V>where
K: Eq + Hash + Clone + Debug,
sourcepub fn new(capacity_order_of_magnitude: usize) -> Self
pub fn new(capacity_order_of_magnitude: usize) -> Self
Create a new LimitedCache with the given rough capacity.
pub fn insert(&mut self, k: K, v: V)
pub fn get<Q>(&self, k: &Q) -> Option<&V>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn remove<Q>(&mut self, k: &Q) -> Option<V>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
Auto Trait Implementations§
impl<K, V> RefUnwindSafe for LimitedCache<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for LimitedCache<K, V>where
K: Send,
V: Send,
impl<K, V> Sync for LimitedCache<K, V>where
K: Sync,
V: Sync,
impl<K, V> Unpin for LimitedCache<K, V>where
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for LimitedCache<K, V>where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
§impl<Tail, T> Prepend<T> for Tail
impl<Tail, T> Prepend<T> for Tail
§type PreprendResult = Tail
type PreprendResult = Tail
The Resulting [
TupleList
], of an [Prepend::prepend()
] call,
including the prepended entry.