Replace
pub struct Replace { /* private fields */ }An in-progress Replace operation.
Methods
deliver_node_max_age
View sourceSets the maximum time the cached item may live on a deliver node in a POP.
Parameters
- self: Self
- duration: Duration
Returns
execute
View sourceFinish using the existing object and start writing a replacement object to the StreamingBody.
The required max_age argument is the "time to live" for the replacement cache item: the time
for which the item will be considered fresh, starting from the start of its history
(now, unless initial_age was provided).
Parameters
- self: Self
- max_age: Duration
Returns
existing_object
View sourceThe existing object, if one exists.
The existing object may be stale.
Parameters
- self: &Self
Returns
header
View sourceSets a single-value header for the replacement object, discarding any previous values
associated with the header name.
Note: These headers are narrowly useful for implementing cache lookups
incorporating the semantics of the HTTP Vary
header, but the APIs in
this module are not suitable for HTTP caching out-of-the-box. Future SDK
releases will contain an HTTP Cache API.
The headers act as additional factors in object selection, and the choice of which
headers to factor in is determined during insertion, via e.g.
crate::cache::core::InsertBuilder::vary_by. A lookup will succeed when there is at least one
cached item that matches lookup's cache key, and all of the lookup's headers included in the cache
items' vary_by list match the corresponding headers in that cached item.
A typical example
is a cached HTTP response, where the request had an Accept-Encoding header. In that case,
the origin server may or may not decide on a given encoding, and whether that same response is
suitable for a request with a different (or missing) Accept-Encoding header is determined
by whether Accept-Encoding is listed in Vary header in the origin's response.
Parameters
- self: Self
- name: impl ToHeaderName
- value: impl ToHeaderValue
Returns
header_values
View sourcefn header_values<'a>(self, name: impl ToHeaderName, values: impl IntoIterator<Item = &'a HeaderValue>) -> SelfSets a multi-value header for the replacement object, discarding any previous values
associated with the header name.
Note: These headers are narrowly useful for implementing cache lookups
incorporating the semantics of the HTTP Vary
header, but the APIs in
this module are not suitable for HTTP caching out-of-the-box. Future SDK
releases will contain an HTTP Cache API.
The headers act as additional factors in object selection, and the choice of which
headers to factor in is determined during insertion, via e.g.
crate::cache::core::InsertBuilder::vary_by. A lookup will succeed when there is at least one
cached item that matches lookup's cache key, and all of the lookup's headers included in the cache
items' vary_by list match the corresponding headers in that cached item.
A typical example
is a cached HTTP response, where the request had an Accept-Encoding header. In that case,
the origin server may or may not decide on a given encoding, and whether that same response is
suitable for a request with a different (or missing) Accept-Encoding header is determined
by whether Accept-Encoding is listed in Vary header in the origin's response.
Parameters
- self: Self
- name: impl ToHeaderName
- values: impl IntoIterator<Item = &'a HeaderValue>
Returns
initial_age
View sourceSets the initial age of the cached item, to be used in freshness calculations.
The initial age is Duration::ZERO by default.
Parameters
- self: Self
- age: Duration
Returns
known_length
View sourcefn known_length(self, length: u64) -> SelfSets the size of the cached item, in bytes, when known prior to actually providing the bytes.
It is preferable to provide a length, if possible. Clients that begin streaming the item's
contents before it is completely provided will see the promised length which allows them to,
for example, use content-length instead of transfer-encoding: chunked if the item is
used as the body of a Request or Response.
Parameters
- self: Self
- length: u64
Returns
sensitive_data
View sourcefn sensitive_data(self, is_sensitive_data: bool) -> SelfEnable or disable PCI/HIPAA-compliant non-volatile caching.
By default, this is false
See the Fastly PCI-Compliant Caching and Delivery documentation for details.
Parameters
- self: Self
- is_sensitive_data: bool
Returns
stale_while_revalidate
View sourceSets the stale-while-revalidate period for the cached item, which is the time for which the item can be safely used despite being considered stale.
Having a stale-while-revalidate period provides a signal that the cache should be updated
(or its contents otherwise revalidated for freshness) asynchronously, while the stale cached
item continues to be used, rather than blocking on updating the cached item. The methods
Found::is_usable and Found::is_stale can be used to determine the current state of
a found item.
The stale-while-revalidate period is Duration::ZERO by default.
Parameters
- self: Self
- duration: Duration
Returns
surrogate_keys
View sourceSets the surrogate keys that can be used for purging this cached item.
Surrogate key purges are the only
means to purge specific items from the cache. At least one surrogate key must be
set in order to remove an item without performing a
purge-all,
waiting for the item's TTL to elapse, or overwriting the item with
crate::cache::core::insert().
Surrogate keys must contain only printable ASCII characters (those between 0x21 and 0x7E, inclusive). Any invalid keys will be ignored.
See the Fastly surrogate keys guide for details.
Parameters
- self: Self
- keys: impl IntoIterator<Item = &'a str>
Returns
user_metadata
View sourceSets the user-defined metadata to associate with the cached item.
Parameters
- self: Self
- user_metadata: Bytes
Returns
vary_by
View sourceSets the list of headers that must match when looking up this cached item.
Note: These headers are narrowly useful for implementing cache lookups
incorporating the semantics of the HTTP Vary
header, but the APIs in
this module are not suitable for HTTP caching out-of-the-box. Future SDK
releases will contain an HTTP Cache API.
The headers act as additional factors in object selection, and the choice of which
headers to factor in is determined during insertion, via e.g.
crate::cache::core::InsertBuilder::vary_by. A lookup will succeed when there is at least one
cached item that matches lookup's cache key, and all of the lookup's headers included in the cache
items' vary_by list match the corresponding headers in that cached item.
A typical example
is a cached HTTP response, where the request had an Accept-Encoding header. In that case,
the origin server may or may not decide on a given encoding, and whether that same response is
suitable for a request with a different (or missing) Accept-Encoding header is determined
by whether Accept-Encoding is listed in Vary header in the origin's response.
Parameters
- self: Self
- headers: impl IntoIterator<Item = &'a HeaderName>
Returns