---
title: purge
summary: Purge the entry associated with the given cache key.
url: https://www.fastly.com/documentation/reference/compute/sdks/cpp/fastly/cache/simple/fn.purge/
---

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

Purge the entry associated with the given cache key.

To configure the behavior of the purge, such as to purge globally rather than within the POP, use [`purge_with_opts()`](https://www.fastly.com/documentation/reference/compute/sdks/cpp/fastly/cache/simple/fn.purge_with_opts/).

Note: Purged values may persist in cache for a short time (~150ms or less) after this function returns.

Example:

_Overload 1 of 2_

```cpp
tl::expected<void, CacheError> fastly::cache::simple::purge(std::span<const std::uint8_t> key)
```

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

Purge the entry associated with the given cache key.

To configure the behavior of the purge, such as to purge globally rather than within the POP, use [`purge_with_opts()`](https://www.fastly.com/documentation/reference/compute/sdks/cpp/fastly/cache/simple/fn.purge_with_opts/).

Note: Purged values may persist in cache for a short time (~150ms or less) after this function returns.

Example:

**Parameters**

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

**Returns**

`tl::expected<void, CacheError>`

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

_Overload 2 of 2_

```cpp
tl::expected<void, CacheError> fastly::cache::simple::purge(std::string_view key)
```

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

Purge the entry associated with the given cache key.

To configure the behavior of the purge, such as to purge globally rather than within the POP, use [`purge_with_opts()`](https://www.fastly.com/documentation/reference/compute/sdks/cpp/fastly/cache/simple/fn.purge_with_opts/).

Note: Purged values may persist in cache for a short time (~150ms or less) after this function returns.

Example:

**Parameters**

- `key`: `std::string_view`

**Returns**

`tl::expected<void, CacheError>`

```cpp
purge("my_key");
```
