---
title: Found
summary: A cached item returned by a lookup.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Found/
---

**Kind:** Struct  
**Module:** [core](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/)  
**Package:** fastly 0.13.1  
**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/cache/core.rs#391

```rust
pub struct Found { /* private fields */ }
```

A cached item returned by a lookup.

This type can be used to [get the cached item as a stream](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Found/#method-to_stream), and to retrieve
its metadata, such as [its size](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Found/#method-known_length) or [whether it's
stale](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Found/#method-is_stale).

## Methods

### age

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/cache/core.rs#417

```rust
fn age(&self) -> Duration
```

The current age of the cached item.

This can be greater than [max age](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Found/#method-max_age) when the item is stale.

**Parameters**

- `self`: `&Self`

**Returns**

`Duration`

### hits

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/cache/core.rs#461

```rust
fn hits(&self) -> u64
```

Determines the number of cache hits to this cached item.

**Note**: this hit count only reflects the view of the server that supplied the cached
item. Due to clustering, this count may vary between potentially many servers within the
data center where the item is cached. See the [clustering
documentation](https://developer.fastly.com/learning/vcl/clustering/) for details, though
note that the exact caching architecture of Compute is different from VCL services.

**Parameters**

- `self`: `&Self`

**Returns**

`u64`

### is_stale

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/cache/core.rs#450

```rust
fn is_stale(&self) -> bool
```

Determines whether the cached item is stale.

A cached item is stale if its age is greater than its max-age period.

**Parameters**

- `self`: `&Self`

**Returns**

`bool`

### is_usable

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/cache/core.rs#443

```rust
fn is_usable(&self) -> bool
```

Determines whether the cached item is usable.

A cached item is usable if its age is less than the sum of the max-age and stale-while-revalidate
periods.

**Parameters**

- `self`: `&Self`

**Returns**

`bool`

### known_length

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/cache/core.rs#430

```rust
fn known_length(&self) -> Option<u64>
```

The size in bytes of the cached item, 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.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<u64>`

### max_age

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/cache/core.rs#401

```rust
fn max_age(&self) -> Duration
```

How long the cached item is/was considered fresh, starting from the start of the cached
item's lifetime.

Note that this is the maximum possible "fresh" age, not the freshness time remaining; see
[remaining_ttl](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Found/#method-remaining_ttl) for that.

**Parameters**

- `self`: `&Self`

**Returns**

`Duration`

### remaining_ttl

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/cache/core.rs#410

```rust
fn remaining_ttl(&self) -> Duration
```

Returns the remaining TTL: how long this cached item has left before it is considered stale.
Zero if the cached item is stale.

Note: this reports the _remaining_ freshness period;
[max age](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Found/#method-max_age) reports the original / intitial TTL.

**Parameters**

- `self`: `&Self`

**Returns**

`Duration`

### stale_while_revalidate

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/cache/core.rs#422

```rust
fn stale_while_revalidate(&self) -> Duration
```

The time during which a stale item can still be used, while it is being revalidated.

**Parameters**

- `self`: `&Self`

**Returns**

`Duration`

### to_stream

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/cache/core.rs#468

```rust
fn to_stream(&self) -> Result<Body, CacheError>
```

Retrieves the entire cached item as a [`Body`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.Body/) that can be read in a streaming fashion.

Only one stream can be active at a time for a given
[`Found`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Found/). The stream must be fully consumed (read) before a new stream
can be created from the same `Found`.
`Err(CacheError::InvalidOperation)` will be returned if a stream is
already active for this [`Found`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Found/). This restriction may be lifted in future
releases.

**Parameters**

- `self`: `&Self`

**Returns**

`Result<Body, CacheError>`

### to_stream_from_range

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/cache/core.rs#511

```rust
fn to_stream_from_range(&self, from: Option<u64>, to: Option<u64>) -> Result<Body, CacheError>
```

Retrieves a range of bytes from the cached item as a [`Body`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.Body/) that can be read in a streaming fashion.

`from` and `to` will determine which bytes are returned:
- If `from` is provided and `to` is not provided, the stream will begin at the `from` byte and
  continue to the end of the body.
- If `from` and `to` are both provided, only the range `from..=to` will be provided.
  Note, both ends are inclusive.
- If `to` is provided but `from` is not provided, the last `to` bytes of the body will be
  provided.

##### Inherently invalid ranges

If `to` is strictly before `from`, this call returns a error immediately.
(`to == from` is acceptable - the bounds are inclusive, so this addresses a single byte.)

##### Known size

The size of a cached item is known if it has completed streaming ([`StreamingBody::finish`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.StreamingBody/#method-finish))
or if the expected length was provided at insert time
([`TransactionInsertBuilder::known_length`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.TransactionInsertBuilder/#method-known_length) and similar).

If the size of the cached item is known, the range is respected only if the range is valid
(`to` is before `from`, and both ranges are less than or equal to the size of the item).
**Otherwise, no error is returned, and the entire body is returned instead.**

##### Unknown size

The size of a cached item may not be known (if `known_length` was not provided and the body
is still being streamed). If the size of the cached item is unknown,
**by default, the range is ignored, and the entire cached item is returned.**

This behavior can be overridden by calling [`TransactionLookupBuilder::always_use_requested_range`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.TransactionLookupBuilder/#method-always_use_requested_range).
If provided, this call will block until the start of the interval is found,
then begin streaming content. The `Body` will generate a read error if the end of the range
is not reached.

##### Re-reading body

Only one stream can be active at a time for a given
[`Found`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Found/). The stream must be fully consumed (read) before a new stream
can be created from the same `Found`.
`Err(CacheError::InvalidOperation)` will be returned if a stream is
already active for this [`Found`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Found/). This restriction may be lifted in future
releases.

**Parameters**

- `self`: `&Self`
- `from`: `Option<u64>`
- `to`: `Option<u64>`

**Returns**

`Result<Body, CacheError>`

### user_metadata

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/cache/core.rs#435

```rust
fn user_metadata(&self) -> Bytes
```

The user-controlled metadata associated with the cached item.

**Parameters**

- `self`: `&Self`

**Returns**

`Bytes`

## Auto trait implementations

- `Freeze`
- `RefUnwindSafe`
- `Send`
- `Sync`
- `Unpin`
- `UnsafeUnpin`
- `UnwindSafe`

## Blanket implementations

- `Any`
- `Borrow<T>`
- `BorrowMut<T>`
- `Downcast`
- `DowncastSync`
- `ErasedDestructor`
- `From<T>`
- `Into<U>`
- `IntoEither`
- `Same`
- `TryFrom<U>`
- `TryInto<U>`
