---
title: insert
summary: Returns an InsertBuilder that will perform a non-transactional cache insertion.
url: https://www.fastly.com/documentation/reference/compute/sdks/cpp/fastly/cache/core/fn.insert/
---

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

Returns an [`InsertBuilder`](https://www.fastly.com/documentation/reference/compute/sdks/cpp/fastly/cache/core/class.InsertBuilder/) that will perform a non-transactional cache insertion.

The required `max_age` argument is the maximal "time to live" for the cache item: the time for which the item will be considered fresh, starting from the start of its history.

_Overload 1 of 2_

```cpp
InsertBuilder fastly::cache::core::insert(std::span<const std::uint8_t> key, std::chrono::nanoseconds max_age)
```

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

Returns an [`InsertBuilder`](https://www.fastly.com/documentation/reference/compute/sdks/cpp/fastly/cache/core/class.InsertBuilder/) that will perform a non-transactional cache insertion.

The required `max_age` argument is the maximal "time to live" for the cache item: the time for which the item will be considered fresh, starting from the start of its history.

**Parameters**

- `key`: `std::span<const std::uint8_t>`
- `max_age`: `std::chrono::nanoseconds`

**Returns**

`InsertBuilder`

_Overload 2 of 2_

```cpp
InsertBuilder fastly::cache::core::insert(std::string_view key, std::chrono::nanoseconds max_age)
```

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

Non-transactional cache insert with string key.

**Parameters**

- `key`: `std::string_view`
- `max_age`: `std::chrono::nanoseconds`

**Returns**

`InsertBuilder`
