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

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

#include <core.h>

Public Member Functions

tl::expected< Replace, CacheErrorbegin () &&
ReplaceBuilder replace_strategy (ReplaceStrategy strategy) &&
 Sets the strategy for performing the replace.
ReplaceBuilder always_use_requested_range () &&

Friends

ReplaceBuilder replace (std::span< const std::uint8_t > key)

Detailed Description

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

Member Function Documentation

◆ always_use_requested_range()

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

Respect the range in to_stream_with_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.

always_use_requested_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 always_use_requested_range behavior will be the default, and this method will be removed.

◆ begin()

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.

◆ replace_strategy()

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

Sets the strategy for performing the replace.

◆ replace

ReplaceBuilder replace ( std::span< const std::uint8_t > key)
friend

Returns a ReplaceBuilder that will perform a non-transactional cache replacement.


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