CacheOverride

Enumin handlefastly 0.13.1View source
1
2
3
4
5
6
7
8
9
10
11
12
pub enum CacheOverride {
None,
Pass,
Override {
ttl: Option<u32>,
stale_while_revalidate: Option<u32>,
stale_if_error: Option<u32>,
pci: bool,
surrogate_key: Option<HeaderValue>,
lookup_timeout_ms: Option<u32>,
},
}

Optional override for response caching behavior. These options mostly apply during host caching, but guest caching also respects them.

Variants

None

Do not override the behavior specified in the origin response's cache control headers.

Pass

Do not cache the response to this request, regardless of the origin response's headers.

Override

Override particular cache control settings.

The origin response's cache control headers will be used for ttl (maxage), stalewhilerevalidate, and staleiferror if None. Note that staleif_error is only supported via the guest caching API.

ttl: Option<u32>

stale_while_revalidate: Option<u32>

stale_if_error: Option<u32>

pci: bool

surrogate_key: Option<http::header::HeaderValue>

lookup_timeout_ms: Option<u32>

Methods

const fn default() -> Self

Return a default set of overrides (no overrides)

Returns

Self

get_lookup_timeout

View source
fn get_lookup_timeout(&self) -> Option<Duration>

Get the lookup timeout period configured on this override

Parameters

self: &Self

Returns

fn get_pci(&self) -> Option<bool>

Get the sensitive-data override setting

Parameters

self: &Self

Returns

Option<bool>

get_stale_if_error

View source
fn get_stale_if_error(&self) -> Option<u32>

Get the SIE period configured on this override

Parameters

self: &Self

Returns

Option<u32>

get_stale_while_revalidate

View source
fn get_stale_while_revalidate(&self) -> Option<u32>

Get the SWR period configured on this override

Parameters

self: &Self

Returns

Option<u32>

get_surrogate_key

View source
fn get_surrogate_key(&self) -> Option<&HeaderValue>

Get the surrogate keys configured on this override

Parameters

self: &Self

Returns

fn get_ttl(&self) -> Option<u32>

Get the TTL configured on this override

Parameters

self: &Self

Returns

Option<u32>
fn is_pass(&self) -> bool

Returns true if this override will cause the request to bypass the cache

Parameters

self: &Self

Returns

bool

lookup_timeout

View source
const fn lookup_timeout(timeout_ms: u32) -> Self

Create a CacheOverride that overrides (only) the cache lookup timeout. Timeout given in milliseconds.

Parameters

timeout_ms: u32

Returns

Self
const fn none() -> Self

Create a CacheOverride that overrides no fields.

Returns

Self
const fn pass() -> Self

Create a CacheOverride forcing a cache bypass.

Returns

Self
const fn pci(pci: bool) -> Self

Create a CacheOverride that overrides (only) the sensitive data bit; if set, prevents the response from being stored in persistent storage

Parameters

pci: bool

Returns

Self

set_lookup_timeout

View source
fn set_lookup_timeout(&mut self, timeout: Duration)

Set the cache lookup timeout configured on this override; value rounded to milliseconds.

Parameters

self: &mut Self
timeout: std::time::Duration

set_none

View source
fn set_none(&mut self)

Updates the CacheOverride to override no fields

Parameters

self: &mut Self

set_pass

View source
fn set_pass(&mut self, pass: bool)

Updates the CacheOverride provide the given Pass behavior; if pass is false, clears all overrides and reverts to the default behavior

Parameters

self: &mut Self
pass: bool
fn set_pci(&mut self, new_pci: bool)

Set the sensitive-data override setting

Parameters

self: &mut Self
new_pci: bool

set_stale_if_error

View source
fn set_stale_if_error(&mut self, new_sie: u32)

Set the SIE period configured on this override

Parameters

self: &mut Self
new_sie: u32

set_stale_while_revalidate

View source
fn set_stale_while_revalidate(&mut self, new_swr: u32)

Set the SWR period configured on this override

Parameters

self: &mut Self
new_swr: u32

set_surrogate_key

View source
fn set_surrogate_key(&mut self, new_surrogate_key: HeaderValue)

Set the surrogate keys configured on this override

Parameters

self: &mut Self
new_surrogate_key: HeaderValue
fn set_ttl(&mut self, new_ttl: u32)

Set the TTL configured on this override

Parameters

self: &mut Self
new_ttl: u32

stale_if_error

View source
const fn stale_if_error(sie: u32) -> Self

Create a CacheOverride that overrides (only) the stale-if-error period

Parameters

sie: u32

Returns

Self

stale_while_revalidate

View source
const fn stale_while_revalidate(swr: u32) -> Self

Create a CacheOverride that overrides (only) the stale-while-revalidate period

Parameters

swr: u32

Returns

Self

surrogate_key

View source
const fn surrogate_key(sk: HeaderValue) -> Self

Create a CacheOverride that overrides (only) the surrogate keys

Parameters

sk: HeaderValue

Returns

Self
const fn ttl(ttl: u32) -> Self

Create a CacheOverride that overrides (only) the TTL

Parameters

ttl: u32

Returns

Self

Trait implementations

impl Clone for CacheOverride

fn clone(&self) -> Self

Parameters

self: &Self

Returns

Self

impl Debug for CacheOverride

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Parameters

self: &Self
f: &mut $crate::fmt::Formatter

Returns

$crate::fmt::Result

impl Default for CacheOverride

fn default() -> Self

Returns

Self

Auto trait implementations

Blanket implementations