Struct pingora_cache::meta::CacheMeta
source · pub struct CacheMeta(/* private fields */);
Expand description
The cacheable response header and cache metadata
Implementations§
source§impl CacheMeta
impl CacheMeta
sourcepub fn new(
fresh_until: SystemTime,
created: SystemTime,
stale_while_revalidate_sec: u32,
stale_if_error_sec: u32,
header: ResponseHeader
) -> CacheMeta
pub fn new( fresh_until: SystemTime, created: SystemTime, stale_while_revalidate_sec: u32, stale_if_error_sec: u32, header: ResponseHeader ) -> CacheMeta
Create a CacheMeta from the given metadata and the response header
sourcepub fn created(&self) -> SystemTime
pub fn created(&self) -> SystemTime
When the asset was created/admitted to cache
sourcepub fn updated(&self) -> SystemTime
pub fn updated(&self) -> SystemTime
The last time the asset was revalidated
This value will be the same as Self::created() if no revalidation ever happens
sourcepub fn is_fresh(&self, time: SystemTime) -> bool
pub fn is_fresh(&self, time: SystemTime) -> bool
Is the asset still valid
sourcepub fn fresh_sec(&self) -> u64
pub fn fresh_sec(&self) -> u64
How long (in seconds) the asset should be fresh since its admission/revalidation
This is essentially the max-age value (or its equivalence)
sourcepub fn fresh_until(&self) -> SystemTime
pub fn fresh_until(&self) -> SystemTime
Until when the asset is considered fresh
sourcepub fn stale_while_revalidate_sec(&self) -> u32
pub fn stale_while_revalidate_sec(&self) -> u32
The stale-while-revalidate limit in seconds
sourcepub fn stale_if_error_sec(&self) -> u32
pub fn stale_if_error_sec(&self) -> u32
The stale-if-error limit in seconds
sourcepub fn serve_stale_while_revalidate(&self, time: SystemTime) -> bool
pub fn serve_stale_while_revalidate(&self, time: SystemTime) -> bool
Can the asset be used to serve stale during revalidation at the given time.
NOTE: the serve stale functions do not check !is_fresh(time), i.e. the object is already assumed to be stale.
sourcepub fn serve_stale_if_error(&self, time: SystemTime) -> bool
pub fn serve_stale_if_error(&self, time: SystemTime) -> bool
Can the asset be used to serve stale after error at the given time.
NOTE: the serve stale functions do not check !is_fresh(time), i.e. the object is already assumed to be stale.
sourcepub fn disable_serve_stale(&mut self)
pub fn disable_serve_stale(&mut self)
Disable serve stale for this asset
sourcepub fn variance(&self) -> Option<HashBinary>
pub fn variance(&self) -> Option<HashBinary>
Get the variance hash of this asset
sourcepub fn set_variance_key(&mut self, variance_key: HashBinary)
pub fn set_variance_key(&mut self, variance_key: HashBinary)
Set the variance key of this asset
sourcepub fn set_variance(&mut self, variance: HashBinary)
pub fn set_variance(&mut self, variance: HashBinary)
Set the variance (hash) of this asset
sourcepub fn remove_variance(&mut self)
pub fn remove_variance(&mut self)
Removes the variance (hash) of this asset
sourcepub fn response_header(&self) -> &ResponseHeader
pub fn response_header(&self) -> &ResponseHeader
Get the response header in this asset
sourcepub fn response_header_mut(&mut self) -> &mut ResponseHeader
pub fn response_header_mut(&mut self) -> &mut ResponseHeader
Modify the header in this asset
sourcepub fn extensions(&self) -> &Extensions
pub fn extensions(&self) -> &Extensions
Expose the extensions to read
sourcepub fn extensions_mut(&mut self) -> &mut Extensions
pub fn extensions_mut(&mut self) -> &mut Extensions
Expose the extensions to modify
sourcepub fn response_header_copy(&self) -> ResponseHeader
pub fn response_header_copy(&self) -> ResponseHeader
Get a copy of the response header
sourcepub fn deserialize(internal: &[u8], header: &[u8]) -> Result<Self>
pub fn deserialize(internal: &[u8], header: &[u8]) -> Result<Self>
Deserialize from the binary format