pub struct FailuresCache<T>{ /* 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() -> FailuresCache<T>
e2e-encryption
only.pub fn with_settings(max_delay: Duration, multiplier: u8) -> FailuresCache<T>
e2e-encryption
only.Sourcepub fn contains<Q>(&self, key: &Q) -> bool
Available on crate feature e2e-encryption
only.
pub fn contains<Q>(&self, key: &Q) -> bool
e2e-encryption
only.Is the given key non-expired and part of the cache.
Sourcepub fn failure_count<Q>(&self, key: &Q) -> Option<u8>
Available on crate feature e2e-encryption
only.
pub fn failure_count<Q>(&self, key: &Q) -> Option<u8>
e2e-encryption
only.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 insert(&self, item: T)
Available on crate feature e2e-encryption
only.
pub fn insert(&self, item: T)
e2e-encryption
only.Add a single item to the cache.
Sourcepub fn extend(&self, iterator: impl IntoIterator<Item = T>)
Available on crate feature e2e-encryption
only.
pub fn extend(&self, iterator: impl IntoIterator<Item = T>)
e2e-encryption
only.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 for FailuresCache<T>
impl<T> Clone for FailuresCache<T>
Source§fn clone(&self) -> FailuresCache<T>
fn clone(&self) -> FailuresCache<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T> Debug for FailuresCache<T>
impl<T> Debug for FailuresCache<T>
Auto 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
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
Arc<>
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more