Transaction
Include fastly/cache/core.h to use this class.
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.
Methods
cancel_insert_or_update
View sourceCancels 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.
Returns
found
View sourceReturns 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.
Returns
insert
View sourceTransactionInsertBuilder 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.
Parameters
- max_age: std::chrono::nanoseconds
Returns
Overload 1 of 2
static TransactionLookupBuilder fastly::cache::core::Transaction::lookup(std::span<const std::uint8_t> key)Returns a TransactionLookupBuilder that will perform a transactional cache lookup.
Parameters
- key: std::span<const std::uint8_t>
Returns
Overload 2 of 2
Transactional cache lookup with string key.
Parameters
- key: std::string_view
Returns
must_insert
View sourcebool fastly::cache::core::Transaction::must_insert() constReturns 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.
Returns
must_insert_or_update
View sourcebool fastly::cache::core::Transaction::must_insert_or_update() constReturns 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()to freshen a found item by updating its metadatainsert()to insert a new item (including object data)cancel_insert_or_update()to exit the transaction without providing an item
Returns
update
View sourceTransactionUpdateBuilder 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.
Parameters
- max_age: std::chrono::nanoseconds
Returns