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

#include <core.h>

Public Member Functions

std::optional< Foundfound () const
bool must_insert () const
bool must_insert_or_update () const
tl::expected< void, CacheErrorcancel_insert_or_update () const
TransactionUpdateBuilder update (std::chrono::nanoseconds max_age) &&
TransactionInsertBuilder insert (std::chrono::nanoseconds max_age) &&

Static Public Member Functions

static TransactionLookupBuilder lookup (std::span< const std::uint8_t > key)
static TransactionLookupBuilder lookup (std::string_view key)
 Transactional cache lookup with string key.

Friends

class TransactionLookupBuilder
class PendingTransaction

Detailed Description

A cache transaction resulting from a transactional lookup.

This type is returned from TransactionLookupBuilder::execute() and provides access to the result of the lookup as well as methods to insert or update cached items when required.

Member Function Documentation

◆ cancel_insert_or_update()

tl::expected< void, CacheError > fastly::cache::core::Transaction::cancel_insert_or_update ( ) const

Cancels the obligation for this transaction client to insert or update a cache item.

If there are concurrent transactional lookups that were blocked waiting on this client to provide the item, one of them will be chosen to be unblocked and given the must_insert_or_update() obligation.

This method should only be called when must_insert_or_update() is true; otherwise, a CacheError::InvalidOperation will be returned.

◆ found()

std::optional< Found > fastly::cache::core::Transaction::found ( ) const

Returns a Found object for this cache item, if one is available.

Even if an object is found, the cache item might be stale and require updating. Use Transaction::must_insert_or_update() to determine whether this transaction client is expected to update the cached item.

◆ insert()

TransactionInsertBuilder fastly::cache::core::Transaction::insert ( std::chrono::nanoseconds max_age) &&

Returns a TransactionInsertBuilder that will perform a transactional cache insertion.

This method should only be called when must_insert_or_update() is true; otherwise, a CacheError::InvalidOperation will be returned when attempting to execute the insertion.

◆ lookup() [1/2]

TransactionLookupBuilder fastly::cache::core::Transaction::lookup ( std::span< const std::uint8_t > key)
static

Returns a TransactionLookupBuilder that will perform a transactional cache lookup.

◆ lookup() [2/2]

TransactionLookupBuilder fastly::cache::core::Transaction::lookup ( std::string_view key)
inlinestatic

Transactional cache lookup with string key.

◆ must_insert()

bool fastly::cache::core::Transaction::must_insert ( ) const

Returns true if a usable cached item was not found, and this transaction client is expected to insert one.

Use insert() to insert the cache item, or cancel_insert_or_update() to exit the transaction without providing an item.

◆ must_insert_or_update()

bool fastly::cache::core::Transaction::must_insert_or_update ( ) const

Returns true if a fresh cache item was not found, and this transaction client is expected to insert a new item or update a stale item.

Use:

◆ update()

TransactionUpdateBuilder fastly::cache::core::Transaction::update ( std::chrono::nanoseconds max_age) &&

Returns a TransactionUpdateBuilder that will perform a transactional cache update.

Updating an item freshens it by updating its metadata, e.g. its age, without changing the object itself.

This method should only be called when must_insert_or_update() is true AND the item is found. Otherwise, a CacheError::InvalidOperation will be returned when attempting to execute the update.

Important note: The TransactionUpdateBuilder will replace ALL of the configuration in the underlying cache item; if any configuration is not set on the builder, it will revert to the default value.

◆ PendingTransaction

friend class PendingTransaction
friend

◆ TransactionLookupBuilder

friend class TransactionLookupBuilder
friend

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