---
title: Found
summary: Found represents a cached object found by a cache lookup.
url: https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/core/struct.Found/
---

**Kind:** Struct  
**Module:** [core](https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/core/)  
**Package:** compute-sdk-go v1.11.0  
**Source:** https://github.com/fastly/compute-sdk-go/blob/d6bf71b04516ed72d6018cab6fff701a865f86e5/cache/core/core.go#L83

```go
type Found struct {
	Key []byte

	TTL time.Duration

	Length uint64

	Age time.Duration

	StaleWhileRevalidate time.Duration

	Hits uint64

	Body io.ReadCloser
	// contains filtered or unexported fields
}
```

Found represents a cached object found by a cache lookup.

## Fields

### Key

**Type:** `[]byte`

Key is the cache key used to find this object.

### TTL

**Type:** `time.Duration`

TTL is the time for which the cached object is considered fresh.

### Length

**Type:** `uint64`

Length is the length of the cached object in bytes, if known.
The length of the cached item may be unknown if the item is
currently being streamed into the cache without a fixed length.

### Age

**Type:** `time.Duration`

Age is the age of the cached object at lookup time.

### StaleWhileRevalidate

**Type:** `time.Duration`

StaleWhileRevalidate is the period of time that the cached object
can be served stale while revalidation takes place.

This provides a signal that the cache should be updated (or its
contents otherwise revalidated for freshness) asynchronously,
while the stale cached object continues to be used, rather than
blocking on updating the cached object.  The default
stale-while-revalidate period is zero.

### Hits

**Type:** `uint64`

Hits is the number of times the cached object has been served.
This count only reflects the view of the server that supplied the
cached object.  Due to clustering, this count may vary between
potentially many servers within the data center where the item is
cached.  See the clustering documentation for details:
https://developer.fastly.com/learning/vcl/clustering/

### Body

**Type:** `io.ReadCloser`

Body is an io.ReadCloser for the cached object.  It must be
closed when finished.

## Methods

### GetRange

**Source:** https://github.com/fastly/compute-sdk-go/blob/d6bf71b04516ed72d6018cab6fff701a865f86e5/cache/core/core.go#L206

```go
func (f *Found) GetRange(from, to uint64) (io.ReadCloser, error)
```

GetRange returns an [io.ReadCloser](https://pkg.go.dev/io#ReadCloser) for the provided range of bytes.
The Found's Body must be closed before calling this function, or it
will return [ErrInvalidOperation].

**Parameters**

- `from`: `uint64`
- `to`: `uint64`

**Returns**

`(io.ReadCloser, error)`

```go
const (
	key      = "my_key"
	contents = "my cached object"
)

w, err := core.Insert([]byte(key), core.WriteOptions{
	TTL:           time.Hour,
	SurrogateKeys: []string{key},
	Length:        uint64(len(contents)),
})
if err != nil {
	panic(err)
}
if _, err := io.WriteString(w, contents); err != nil {
	panic(err)
}
if err := w.Close(); err != nil {
	panic(err)
}

f, err := core.Lookup([]byte("my_key"), core.LookupOptions{})
if err != nil {
	panic(err)
}

if err := f.Body.Close(); err != nil {
	panic(err)
}

_, err = f.GetRange(3, 1)
if err == nil {
	panic("accepted invalid range")
}

body, err := f.GetRange(3, 0)
if err == nil {
	panic("accepted invalid range")
}
cachedStr, err := io.ReadAll(body)
if err != nil {
	panic(err)
}
if string(cachedStr) != "cached object" {
	panic(fmt.Sprintf("got: %q, want: %q", cachedStr, "cached object"))
}

fmt.Printf("The cached value was: %s", cachedStr)
```

### Stale

**Source:** https://github.com/fastly/compute-sdk-go/blob/d6bf71b04516ed72d6018cab6fff701a865f86e5/cache/core/core.go#L177

```go
func (f *Found) Stale() bool
```

Stale returns true if the cached object is stale.

**Returns**

`bool`

### Usable

**Source:** https://github.com/fastly/compute-sdk-go/blob/d6bf71b04516ed72d6018cab6fff701a865f86e5/cache/core/core.go#L182

```go
func (f *Found) Usable() bool
```

Usable returns true if the cached object is usable.

**Returns**

`bool`

### UserMetadata

**Source:** https://github.com/fastly/compute-sdk-go/blob/d6bf71b04516ed72d6018cab6fff701a865f86e5/cache/core/core.go#L189

```go
func (f *Found) UserMetadata() ([]byte, error)
```

UserMetadata returns user-provided metadata associated with the
cached object.  It will return an empty slice if no metadata was
provided when the object was inserted.

**Returns**

`([]byte, error)`
