ReplaceBuilder

Classin corecompute-sdk-cpp 0.7.0View source

Include fastly/cache/core.h to use this class.

A builder-style API for configuring a non-transactional cache replacement.

Methods

always_use_requested_range

View source
ReplaceBuilder fastly::cache::core::ReplaceBuilder::always_use_requested_range() &&

Respect the range in tostreamwith_range even when the body length is not yet known.

When a cache item is Found, the length of the cached item may or may not be known:

  • the item may be fully cached;
  • the item may be streaming in, but have a known length; or
  • the item may be streaming in progressively, without a known length.

By default (legacy behavior), if a range is specified but the length is not known, the contents of the entire item will be provided instead of the requested range.

alwaysuserequested_range indicates any cached item returned by this lookup should provide only the requested range, regardless of whether the length is known. An invalid range will eventually return a read error, possibly after providing some data.

NOTE: In the future, the alwaysuserequested_range behavior will be the default, and this method will be removed.

Returns

tl::expected<Replace, CacheError> fastly::cache::core::ReplaceBuilder::begin() &&

Begin the replace, returning a Replace for reading the object to be replaced (if it exists) which is also used to provide the new replacement object.

A Replace gives access to the existing object, if one is stored, that may be used to construct the replacement object. Use Replace::execute() to get a StreamingBody to write the replacement object into. The existing object cannot be accessed after calling Replace::execute().

For the replace 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 replacement 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.

Returns

tl::expected<Replace, CacheError>

replace_strategy

View source
ReplaceBuilder fastly::cache::core::ReplaceBuilder::replace_strategy(ReplaceStrategy strategy) &&

Sets the strategy for performing the replace.

Parameters

strategy: ReplaceStrategy

Returns