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,
§impl<T> CompatExt for T
impl<T> CompatExt for T
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Consume a handle, getting back the initial
Arc<>