pub struct Entry<V> { /* private fields */ }Expand description
A cheaply-cloneable handle to a cached value and its metadata.
Entries are immutable; “mutating” an entry (throttling a stale value,
refreshing it) produces a new Entry that replaces the old one. This avoids
interior mutability and makes every stored value safe to share across tasks.
Implementations§
Source§impl<V> Entry<V>
impl<V> Entry<V>
Sourcepub fn backend_ttl(&self) -> Duration
pub fn backend_ttl(&self) -> Duration
The TTL to hand the backend’s expiry policy.
Sourcepub fn is_logically_expired(&self, now: Timestamp) -> bool
pub fn is_logically_expired(&self, now: Timestamp) -> bool
true if the entry is logically expired at now.
Sourcepub fn is_physically_expired(&self, now: Timestamp) -> bool
pub fn is_physically_expired(&self, now: Timestamp) -> bool
true if now is at/after the physical boundary (the entry is dead and
no longer usable even as a fail-safe fallback).
Sourcepub fn should_eager_refresh(&self, now: Timestamp) -> bool
pub fn should_eager_refresh(&self, now: Timestamp) -> bool
true if a proactive background refresh should start now.
Source§impl<V> Entry<V>
impl<V> Entry<V>
Sourcepub fn fresh(
value: V,
options: &EntryOptions,
created: Timestamp,
tags: Box<[Tag]>,
etag: Option<String>,
last_modified: Option<Timestamp>,
) -> Self
pub fn fresh( value: V, options: &EntryOptions, created: Timestamp, tags: Box<[Tag]>, etag: Option<String>, last_modified: Option<Timestamp>, ) -> Self
Builds a fresh entry from a freshly-produced value.
Sourcepub fn throttled(
source: &Entry<V>,
options: &EntryOptions,
now: Timestamp,
) -> Option<Self>where
V: Clone,
pub fn throttled(
source: &Entry<V>,
options: &EntryOptions,
now: Timestamp,
) -> Option<Self>where
V: Clone,
Builds a throttled fail-safe entry that re-serves an existing value for the throttle window, keeping the original physical boundary.
Returns None when the source value is already physically expired and so
cannot be reused.
Sourcepub fn with_logical_expiration(&self, at: Timestamp) -> Selfwhere
V: Clone,
pub fn with_logical_expiration(&self, at: Timestamp) -> Selfwhere
V: Clone,
Produces a copy of this entry that is logically expired as of at, while
keeping the original physical boundary so fail-safe can still serve it.
Used by Cache::expire.
Sourcepub fn rehydrate(
value: V,
created: Timestamp,
logical_expiration: Timestamp,
physical_expiration: Timestamp,
is_from_fail_safe: bool,
etag: Option<String>,
last_modified: Option<Timestamp>,
tags: Box<[Tag]>,
now: Timestamp,
) -> Self
pub fn rehydrate( value: V, created: Timestamp, logical_expiration: Timestamp, physical_expiration: Timestamp, is_from_fail_safe: bool, etag: Option<String>, last_modified: Option<Timestamp>, tags: Box<[Tag]>, now: Timestamp, ) -> Self
Rebuilds an in-memory entry from data read out of the L2 distributed cache, recomputing the backend TTL from the (absolute) physical boundary.
Sourcepub fn from_fail_safe_default(
value: V,
options: &EntryOptions,
now: Timestamp,
) -> Self
pub fn from_fail_safe_default( value: V, options: &EntryOptions, now: Timestamp, ) -> Self
Builds a fail-safe entry from a default value (the fail_safe_default),
throttled like throttled.