pub struct Found { /* private fields */ }
Expand description
A cached item returned by a lookup.
This type can be used to get the cached item as a stream, and to retrieve its metadata, such as its size or whether it’s stale.
Implementations§
source§impl Found
impl Found
sourcepub fn stale_while_revalidate(&self) -> Duration
pub fn stale_while_revalidate(&self) -> Duration
The time for which a cached item can safely be used despite being considered stale.
sourcepub fn known_length(&self) -> Option<u64>
pub fn known_length(&self) -> Option<u64>
The size in bytes of the cached item, if known.
The length of the cached item may be unknown if the item is currently being streamed into the cache without a fixed length.
sourcepub fn user_metadata(&self) -> Bytes
pub fn user_metadata(&self) -> Bytes
The user-controlled metadata associated with the cached item.
sourcepub fn is_usable(&self) -> bool
pub fn is_usable(&self) -> bool
Determines whether the cached item is usable.
A cached item is usable if its age is less than the sum of the TTL and stale-while-revalidate periods.
sourcepub fn is_stale(&self) -> bool
pub fn is_stale(&self) -> bool
Determines whether the cached item is stale.
A cached item is stale if its age is greater than its TTL period.
sourcepub fn hits(&self) -> u64
pub fn hits(&self) -> u64
Determines the number of cache hits to this cached item.
Note: this hit count only reflects the view of the server that supplied the cached item. Due to clustering, this count may vary between potentially many servers within the data center where the item is cached. See the clustering documentation for details, though note that the exact caching architecture of Compute is different from VCL services.
sourcepub fn to_stream(&self) -> Result<Body, CacheError>
pub fn to_stream(&self) -> Result<Body, CacheError>
sourcepub fn to_stream_from_range(
&self,
from: Option<u64>,
to: Option<u64>
) -> Result<Body, CacheError>
pub fn to_stream_from_range( &self, from: Option<u64>, to: Option<u64> ) -> Result<Body, CacheError>
Retrieves a range of bytes from the cached item as a Body
that can be read in a streaming fashion.
If from
is None
, the stream will start from the beginning of the item. If to
is
None
, the stream will end at the end of the item.
If the provided range is invalid, the stream will contain the entire item. It is the caller’s responsibility to check that the returned stream contains the number of bytes expected.
Only one stream can be active at a time for a given
Found
. Err(CacheError::InvalidOperation)
will be returned if a stream is
already active for this Found
. This restriction may be lifted in future
releases.