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

Namespaces

namespace  detail

Classes

class  CacheError
 Errors that can arise during cache operations. More...
class  Found
class  InsertBuilder
class  LookupBuilder
struct  LookupOptions
 Options for cache lookup operations. More...
class  PendingTransaction
class  Replace
class  ReplaceBuilder
 A builder-style API for configuring a non-transactional cache replacement. More...
struct  ReplaceOptions
 Options for cache replace operations. More...
class  Transaction
class  TransactionInsertBuilder
class  TransactionLookupBuilder
 A builder-style API for configuring a transactional cache lookup. More...
class  TransactionUpdateBuilder
struct  WriteOptions
 Options for cache write operations (insert/update). More...

Enumerations

enum class  ReplaceStrategy { Immediate , ImmediateForceMiss , Wait }
 Strategy to use when replacing an existing cached object. More...

Functions

LookupBuilder lookup (std::span< const std::uint8_t > key)
LookupBuilder lookup (std::string_view key)
 Non-transactional cache lookup with string key.
InsertBuilder insert (std::span< const std::uint8_t > key, std::chrono::nanoseconds max_age)
InsertBuilder insert (std::string_view key, std::chrono::nanoseconds max_age)
 Non-transactional cache insert with string key.
ReplaceBuilder replace (std::span< const std::uint8_t > key)
ReplaceBuilder replace (std::string_view key)
 Non-transactional cache replace with string key.

Enumeration Type Documentation

◆ ReplaceStrategy

Strategy to use when replacing an existing cached object.

Enumerator
Immediate 

Immediately start the replace and do not wait for any other pending requests for the same object, including insert requests.

With this strategy a replace will race all other pending requests to update the object.

The existing object will be accessible until this replace finishes providing the replacement object.

This is the default replace strategy.

ImmediateForceMiss 

Immediate, but remove the existing object immediately

Requests for the same object that arrive after this replace starts will wait until this replace starts providing the replacement object.

Wait 

Join the wait list behind other pending requests before starting this request.

With this strategy this replace request will wait for an in-progress replace or insert request before starting.

This strategy allows implementing a counter, but may cause timeouts if too many requests are waiting for in-progress and waiting updates to complete.

Function Documentation

◆ insert() [1/2]

InsertBuilder fastly::cache::core::insert ( std::span< const std::uint8_t > key,
std::chrono::nanoseconds max_age )

Returns an InsertBuilder that will perform a non-transactional cache insertion.

The required max_age argument is the maximal "time to live" for the cache item: the time for which the item will be considered fresh, starting from the start of its history.

◆ insert() [2/2]

InsertBuilder fastly::cache::core::insert ( std::string_view key,
std::chrono::nanoseconds max_age )
inline

Non-transactional cache insert with string key.

◆ lookup() [1/2]

LookupBuilder fastly::cache::core::lookup ( std::span< const std::uint8_t > key)

Returns a LookupBuilder that will perform a non-transactional cache lookup.

In contrast to Transaction::lookup(), a non-transactional lookup will not attempt to coordinate with any concurrent cache lookups. If two instances of the service perform a lookup at the same time for the same cache key, and the item is not yet cached, they will both get nothing from the eventual lookup execution. Without further coordination, they may both end up performing the work needed to insert() the item (which usually involves origin requests and/or computation) and racing with each other to insert.

To resolve such races between concurrent lookups, use Transaction::lookup() instead.

◆ lookup() [2/2]

LookupBuilder fastly::cache::core::lookup ( std::string_view key)
inline

Non-transactional cache lookup with string key.

◆ replace() [1/2]

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

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

◆ replace() [2/2]

ReplaceBuilder fastly::cache::core::replace ( std::string_view key)
inline

Non-transactional cache replace with string key.