pub struct ExpiringSet<K>(/* private fields */);Expand description
A set version of ExpiringMap. Sets V to ()
Implementations§
Source§impl<K: PartialEq + Eq + Hash> ExpiringSet<K>
impl<K: PartialEq + Eq + Hash> ExpiringSet<K>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new ExpiringSet
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a new ExpiringSet with the specified capacity
Sourcepub fn insert(&mut self, key: K, ttl: Duration) -> bool
pub fn insert(&mut self, key: K, ttl: Duration) -> bool
Returns true if the set contains this value
Sourcepub fn take<Q>(&mut self, key: &Q) -> Option<K>
pub fn take<Q>(&mut self, key: &Q) -> Option<K>
If it exists and has not expired, remove and return the value at this key
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrink the set to the minimum allowable size in accordance with the resize policy
Methods from Deref<Target = ExpiringMap<K, ()>>§
Sourcepub fn vacuum(&mut self)
pub fn vacuum(&mut self)
Shrinks the hashmap based on entries that should no longer be contained. This is O(n).
Sourcepub fn vacuum_if_needed(&mut self)
pub fn vacuum_if_needed(&mut self)
execute a vacuum if the map has grown by more than 1.5 times
Sourcepub fn get_meta<Q>(&self, key: &Q) -> Option<&ExpiryValue<V>>
pub fn get_meta<Q>(&self, key: &Q) -> Option<&ExpiryValue<V>>
If the value exists and has not expired, return its expiry data
Sourcepub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
If a key exists for this value, get both the key and value if it is not expired
Sourcepub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
Get a mutable reference to the value pointed to by a key, if it is not expired
Sourcepub fn insert(
&mut self,
key: K,
value: V,
ttl: Duration,
) -> Option<ExpiryValue<V>>
pub fn insert( &mut self, key: K, value: V, ttl: Duration, ) -> Option<ExpiryValue<V>>
Insert a value into the map, returning the old value if it has not expired and existed
Sourcepub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
If this key exists and is not expired, returns true
Sourcepub fn remove<Q>(&mut self, key: &Q) -> bool
pub fn remove<Q>(&mut self, key: &Q) -> bool
Remove an item from the map. If it exists and has not expired, return true
Sourcepub fn reserve(&mut self, addtional: usize)
pub fn reserve(&mut self, addtional: usize)
Reserve at least a certain capacity on the internal map
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Remove all of the expired entries and shrink the map to the minimum allowable size in accordance with the resize policy