---
title: simple
summary: Package simple provides the Simple Cache API, a simplified interface to inserting and retrieving entries from Fastly's cache.
url: https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/simple/
---

**Kind:** Module  
**Package:** compute-sdk-go v1.11.0  
**Path:** `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](https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/core/) package.

## Structs

| Name | Summary |
| --- | --- |
| [CacheEntry](https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/simple/struct.CacheEntry/) | CacheEntry contains the contents and TTL (time-to-live) for an item to be added to the cache via [GetOrSet](https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/simple/fn.GetOrSet/) or [GetOrSetContents]. |
| [PurgeOptions](https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/simple/struct.PurgeOptions/) | PurgeOptions controls the behavior of the [Purge](https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/simple/fn.Purge/) function. |

## Enums

| Name | Summary |
| --- | --- |
| [PurgeScope](https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/simple/enum.PurgeScope/) | PurgeScope controls the scope of a purge operation.  It is used in the [PurgeOptions](https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/simple/struct.PurgeOptions/) struct. |

## Functions

| Name | Summary |
| --- | --- |
| [Get](https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/simple/fn.Get/) | Get 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. |
| [GetOrSet](https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/simple/fn.GetOrSet/) | GetOrSet 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. |
| [GetOrSetEntry](https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/simple/fn.GetOrSetEntry/) | GetOrSetEntry retrieves the object stored in the cache for the given key if it exists, or inserts and returns the contents provided in the [CacheEntry](https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/simple/struct.CacheEntry/). |
| [Purge](https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/simple/fn.Purge/) | Purge removes the entry associated with the given cache key, if one exists. |
| [SurrogateKeyForCacheKey](https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/simple/fn.SurrogateKeyForCacheKey/) | SurrogateKeyForCacheKey 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

**Type:** `PurgeScope`  
**Default:** `1`  
**Flags:** read-only  
**Source:** https://github.com/fastly/compute-sdk-go/blob/d6bf71b04516ed72d6018cab6fff701a865f86e5/cache/simple/simple.go#L134

PurgeScopeGlobal purges the entry from all POP caches.

### PurgeScopePOP

**Type:** `PurgeScope`  
**Default:** `iota`  
**Flags:** read-only  
**Source:** https://github.com/fastly/compute-sdk-go/blob/d6bf71b04516ed72d6018cab6fff701a865f86e5/cache/simple/simple.go#L132

PurgeScopePOP purges the entry only from the local POP cache.
