pub struct OriginProbeMemo { /* private fields */ }Expand description
Bounded, lazily-expiring memo of origin-probe answers.
Implementations§
Source§impl OriginProbeMemo
impl OriginProbeMemo
Sourcepub fn new(policy: OriginProbePolicy) -> Self
pub fn new(policy: OriginProbePolicy) -> Self
A memo under policy. A capacity of 0 is treated as 1 so the map can
always hold the entry it just resolved.
Sourcepub const fn fault_ttl(&self) -> Duration
pub const fn fault_ttl(&self) -> Duration
How long a memoised Fault answer stands before the origin is
re-probed.
Sourcepub const fn timeout(&self) -> Duration
pub const fn timeout(&self) -> Duration
The per-probe live-HEAD ceiling this memo was configured with.
Sourcepub fn get(&mut self, hash: Hash, now: Instant) -> Option<Presence>
pub fn get(&mut self, hash: Hash, now: Instant) -> Option<Presence>
A live (non-expired) memoised answer for hash, or None on a miss.
Expired entries are swept in passing so a stale answer is never returned
and the map does not accrete dead entries on the read path.
Sourcepub fn insert(&mut self, hash: Hash, presence: Presence, now: Instant)
pub fn insert(&mut self, hash: Hash, presence: Presence, now: Instant)
Record presence for hash, valid for one TTL from now. Enforces the
capacity bound: expired entries are swept first, and if the map is still
at capacity one arbitrary live entry is dropped to make room, so the memo
can never exceed capacity distinct hashes regardless of probe volume.
Trait Implementations§
Source§impl Debug for OriginProbeMemo
impl Debug for OriginProbeMemo
Auto Trait Implementations§
impl Freeze for OriginProbeMemo
impl RefUnwindSafe for OriginProbeMemo
impl Send for OriginProbeMemo
impl Sync for OriginProbeMemo
impl Unpin for OriginProbeMemo
impl UnsafeUnpin for OriginProbeMemo
impl UnwindSafe for OriginProbeMemo
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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