---
title: lookup
summary: Returns a LookupBuilder that will perform a non-transactional cache lookup.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/fn.lookup/
---

**Kind:** Function  
**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#150

```rust
fn lookup(key: CacheKey) -> LookupBuilder
```

Returns a [`LookupBuilder`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.LookupBuilder/) that will perform a non-transactional cache lookup.

```rust
let mut cached_string = String::new();
if let Some(entry) = lookup(CacheKey::from_static(b"my_key")).execute()? {
    entry
        .to_stream()?
        .read_to_string(&mut cached_string)?;
}
println!("the cached string was: {cached_string}");
```

#### Relationship with [`Transaction::lookup()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Transaction/#method-lookup)

In contrast to [`Transaction::lookup()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Transaction/#method-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
`Ok(None)` from the eventual lookup execution. Without further coordination, they may both end
up performing the work needed to [`insert()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/fn.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()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/core/struct.Transaction/#method-lookup) instead.

**Parameters**

- `key`: `CacheKey`

**Returns**

`LookupBuilder`
