Struct matrix_sdk_common::failures_cache::FailuresCache
source · pub struct FailuresCache<T: Eq + Hash> { /* private fields */ }
Expand description
A TTL cache where items get inactive instead of discarded.
The items need to be explicitly removed from the cache. This allows us to implement exponential backoff based TTL.
Implementations§
source§impl<T> FailuresCache<T>
impl<T> FailuresCache<T>
pub fn new() -> Self
pub fn with_settings(max_delay: Duration, multiplier: u8) -> Self
sourcepub fn failure_count<Q>(&self, key: &Q) -> Option<u8>
pub fn failure_count<Q>(&self, key: &Q) -> Option<u8>
Get the failure count for a given key.
§Returns
-
None
if this key is not in the failure cache. (It has never failed, or it has beenFailuresCache::remove()
d since the last failure.) -
Some(u8)
: the number of times it has failed since it was first added to the failure cache. (In other words, one less than the total number of failures.)
sourcepub fn extend(&self, iterator: impl IntoIterator<Item = T>)
pub fn extend(&self, iterator: impl IntoIterator<Item = T>)
Extend the cache with the given iterator of items.
Items that are already part of the cache, whether they are expired or not, will have their TTL extended using an exponential backoff algorithm.
Trait Implementations§
source§impl<T: Clone + Eq + Hash> Clone for FailuresCache<T>
impl<T: Clone + Eq + Hash> Clone for FailuresCache<T>
source§fn clone(&self) -> FailuresCache<T>
fn clone(&self) -> FailuresCache<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<T> Freeze for FailuresCache<T>
impl<T> RefUnwindSafe for FailuresCache<T>
impl<T> Send for FailuresCache<T>
impl<T> Sync for FailuresCache<T>
impl<T> Unpin for FailuresCache<T>
impl<T> UnwindSafe for FailuresCache<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)