---
title: get
summary: Get the entry associated with the given cache key, if it exists.
url: https://www.fastly.com/documentation/reference/compute/sdks/cpp/fastly/cache/simple/fn.get/
---

**Kind:** Function  
**Module:** [simple](https://www.fastly.com/documentation/reference/compute/sdks/cpp/fastly/cache/simple/)  
**Package:** compute-sdk-cpp 0.7.0

Get the entry associated with the given cache key, if it exists.

Returns `nullopt` if the key is not in the cache, or `Body` with the cached value if found.

_Overload 1 of 2_

```cpp
tl::expected<std::optional<http::Body>, CacheError> fastly::cache::simple::get(std::span<const std::uint8_t> key)
```

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/cache/simple.h#L114

Get the entry associated with the given cache key, if it exists.

Returns `nullopt` if the key is not in the cache, or `Body` with the cached value if found.

**Parameters**

- `key`: `std::span<const std::uint8_t>`

**Returns**

`tl::expected<std::optional<http::Body>, CacheError>`

```cpp
std::vector<std::uint8_t> key_bytes = {0x01, 0x02, 0x03};
auto result = get(key_bytes);
```

_Overload 2 of 2_

```cpp
tl::expected<std::optional<http::Body>, CacheError> fastly::cache::simple::get(std::string_view key)
```

**Source:** https://github.com/fastly/compute-sdk-cpp/blob/ff911e47be2f319e83a9cde960d2c3c5db534280/include/fastly/cache/simple.h#L125

Get the entry associated with the given cache key, if it exists.

Returns `nullopt` if the key is not in the cache, or `Body` with the cached value if found.

**Parameters**

- `key`: `std::string_view`

**Returns**

`tl::expected<std::optional<http::Body>, CacheError>`

```cpp
auto result = get("my_key");
```
