Modulecompute-sdk-go v1.11.0

github.com/fastly/compute-sdk-go/cache/simple

Package simple provides the Simple Cache API, a simplified interface to inserting and retrieving entries from Fastly's cache.

Cache operations are local to the Fastly POP serving the request. Purging can also be performed globally.

For more advanced uses, see the Core Cache API in the github.com/fastly/compute-sdk-go/cache/core package.

Structs

CacheEntryCacheEntry contains the contents and TTL (time-to-live) for an item to be added to the cache via GetOrSet or [GetOrSetContents].
PurgeOptionsPurgeOptions controls the behavior of the Purge function.

Enums

PurgeScopePurgeScope controls the scope of a purge operation. It is used in the PurgeOptions struct.

Functions

GetGet retrieves the object stored in the cache for the given key. If the key is not cached, [core.ErrNotFound] is returned. Keys can be up to 4096 bytes in length.
GetOrSetGetOrSet retrieves the object stored in the cache for the given key if it exists, or inserts and returns the contents by running the provided setFn function.
GetOrSetEntryGetOrSetEntry retrieves the object stored in the cache for the given key if it exists, or inserts and returns the contents provided in the CacheEntry.
PurgePurge removes the entry associated with the given cache key, if one exists.
SurrogateKeyForCacheKeySurrogateKeyForCacheKey creates a surrogate key for the given cache key and purge scope that is compatible with the Simple Cache API. Each cache entry for the Simple Cache API is configured with surrogate keys from this function.

Constants

PurgeScopeGlobal

PurgeScoperead-onlyView source

Default: 1

PurgeScopeGlobal purges the entry from all POP caches.

PurgeScopePOP

PurgeScoperead-onlyView source

Default: iota

PurgeScopePOP purges the entry only from the local POP cache.