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

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

```rust
fn purge_with_opts(key: impl Into<CacheKey>, opts: PurgeOptions) -> Result<(), CacheError>
```

Purge the entry associated with the given cache key.

The [`PurgeOptions`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/cache/simple/struct.PurgeOptions/) argument determines the scope of the purge operation.

##### Note

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

#### Argument type conversion

See the `From` impls for [`Bytes`](https://docs.rs/bytes/latest/bytes/bytes/struct.Bytes.html) to see which types can be used
as a key.

##### Example POP-scoped purge

```rust
purge_with_opts("my_key", PurgeOptions::pop_scope())?;
```

Note that this is the default behavior, and is therefore equivalent to:

```rust
purge("my_key")?;
```

##### Example global-scoped purge

```rust
purge_with_opts("my_key", PurgeOptions::global_scope())?;
```

This purging mode is subject to the same rate limits as other forms of global
[purging on
Fastly](https://developer.fastly.com/learning/concepts/purging/#limitations-and-constraints). You
should use POP scope where possible, and can contact <support@fastly.com> with
questions if you encounter rate limiting issues.

**Parameters**

- `key`: `impl Into<CacheKey>`
- `opts`: `PurgeOptions`

**Returns**

`Result<(), CacheError>`
