Struct fastly::cache::core::Found

source ·
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

source

pub fn ttl(&self) -> Duration

The time for which the cached item is considered fresh.

source

pub fn age(&self) -> Duration

The current age of the cached item.

source

pub fn stale_while_revalidate(&self) -> Duration

The time for which a cached item can safely be used despite being considered stale.

source

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.

source

pub fn user_metadata(&self) -> Bytes

The user-controlled metadata associated with the cached item.

source

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.

source

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.

source

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.

source

pub fn to_stream(&self) -> Result<Body, CacheError>

Retrieves the entire cached item as a Body that can be read in a streaming fashion.

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.

source

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.

Auto Trait Implementations§

§

impl RefUnwindSafe for Found

§

impl Send for Found

§

impl Sync for Found

§

impl Unpin for Found

§

impl UnwindSafe for Found

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.