Fastly Compute C++ SDK
Loading...
Searching...
No Matches
fastly::cache::core::TransactionInsertBuilder Class Reference

#include <core.h>

Public Member Functions

TransactionInsertBuilder vary_by (std::vector< std::string > headers) &&
TransactionInsertBuilder initial_age (std::chrono::nanoseconds age) &&
TransactionInsertBuilder stale_while_revalidate (std::chrono::nanoseconds duration) &&
TransactionInsertBuilder surrogate_keys (std::vector< std::string > keys) &&
TransactionInsertBuilder known_length (std::uint64_t length) &&
TransactionInsertBuilder user_metadata (std::vector< std::uint8_t > metadata) &&
 Sets the user-defined metadata to associate with the cached item.
TransactionInsertBuilder sensitive_data (bool is_sensitive) &&
TransactionInsertBuilder deliver_node_max_age (std::chrono::nanoseconds duration) &&
 Sets the maximum time the cached item may live on a deliver node in a POP.
TransactionInsertBuilder on_behalf_of (std::string service) &&
tl::expected< http::StreamingBody, CacheErrorexecute () &&
tl::expected< std::pair< http::StreamingBody, Found >, CacheErrorexecute_and_stream_back () &&

Friends

class Transaction

Detailed Description

A builder-style API for configuring a transactional cache insertion.

This builder is used to insert a new item into the cache during a transaction. All builder methods consume the builder and return it for method chaining.

Member Function Documentation

◆ deliver_node_max_age()

TransactionInsertBuilder fastly::cache::core::TransactionInsertBuilder::deliver_node_max_age ( std::chrono::nanoseconds duration) &&

Sets the maximum time the cached item may live on a deliver node in a POP.

◆ execute()

tl::expected< http::StreamingBody, CacheError > fastly::cache::core::TransactionInsertBuilder::execute ( ) &&

Begin the insertion, returning a StreamingBody for providing the cached object itself.

For the insertion to complete successfully, the object must be written into the StreamingBody, and then StreamingBody::finish must be called. If the StreamingBody is dropped before calling StreamingBody::finish, the insertion is considered incomplete, and any concurrent lookups that may be reading from the object as it is streamed into the cache may encounter a streaming error.

◆ execute_and_stream_back()

tl::expected< std::pair< http::StreamingBody, Found >, CacheError > fastly::cache::core::TransactionInsertBuilder::execute_and_stream_back ( ) &&

Begin the insertion, and provide a Found object that can be used to stream out of the newly-inserted object.

For the insertion to complete successfully, the object must be written into the StreamingBody, and then StreamingBody::finish must be called. If the StreamingBody is dropped before calling StreamingBody::finish, the insertion is considered incomplete, and any concurrent lookups that may be reading from the object as it is streamed into the cache may encounter a streaming error.

The returned Found object allows the client inserting a cache item to efficiently read back the contents of that item, avoiding the need to buffer contents for copying to multiple destinations. This pattern is commonly required when caching an item that also must be provided to, e.g., the client response.

◆ initial_age()

TransactionInsertBuilder fastly::cache::core::TransactionInsertBuilder::initial_age ( std::chrono::nanoseconds age) &&

Sets the initial age of the cached item, to be used in freshness calculations. The initial age is 0 by default.

◆ known_length()

TransactionInsertBuilder fastly::cache::core::TransactionInsertBuilder::known_length ( std::uint64_t length) &&

Sets 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.

◆ on_behalf_of()

TransactionInsertBuilder fastly::cache::core::TransactionInsertBuilder::on_behalf_of ( std::string service) &&

Perform this insert on behalf of another service, using its data store.

Internal / Privileged This operation is privileged, and attempts to use this functionality without proper privileges will cause errors. If you are interested in having two or more of your services share the same cache, please talk to your Fastly account representative. While we have no plans to offer this ability widely – this capability is only currently allowed for Fastly-internal services – we may revisit this decision given sufficient customer input.

◆ sensitive_data()

TransactionInsertBuilder fastly::cache::core::TransactionInsertBuilder::sensitive_data ( bool is_sensitive) &&

Enable or disable PCI/HIPAA-compliant non-volatile caching.

By default, this is false.

See the Fastly PCI-Compliant Caching and Delivery documentation for details.

◆ stale_while_revalidate()

TransactionInsertBuilder fastly::cache::core::TransactionInsertBuilder::stale_while_revalidate ( std::chrono::nanoseconds duration) &&

Sets 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 0 by default.

◆ surrogate_keys()

TransactionInsertBuilder fastly::cache::core::TransactionInsertBuilder::surrogate_keys ( std::vector< std::string > keys) &&

Sets 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.

◆ user_metadata()

TransactionInsertBuilder fastly::cache::core::TransactionInsertBuilder::user_metadata ( std::vector< std::uint8_t > metadata) &&

Sets the user-defined metadata to associate with the cached item.

◆ vary_by()

TransactionInsertBuilder fastly::cache::core::TransactionInsertBuilder::vary_by ( std::vector< std::string > headers) &&

Sets the list of headers that must match when looking up this cached item.

The header values must be provided by calling TransactionLookupBuilder::header() or TransactionLookupBuilder::header_values(). The header values may be a subset or superset of the header names supplied here.

◆ Transaction

friend class Transaction
friend

The documentation for this class was generated from the following file: