# WithPersistence

- Module: [Aspire.Hosting.Redis](/reference/api/go/aspire.hosting.redis.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: [`RedisResource`](/reference/api/go/aspire.hosting.redis/redisresource.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Configures a Redis container resource for persistence.

## Definition

```go
func (RedisResource) WithPersistence(options ...*WithPersistenceOptions) RedisResource
```

## Parameters

- `options` (`...*WithPersistenceOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*WithPersistenceOptions` argument.

- `Interval` (`*float64`) -- The interval between snapshot exports. Defaults to 60 seconds.
- `KeysChangedThreshold` (`*float64`) -- The number of key change operations required to trigger a snapshot at the interval. Defaults to 1.

## Returns

[`RedisResource`](/reference/api/go/aspire.hosting.redis/redisresource.md) -- The resource builder.

Returns a handle; failures surface later via `Err()`.

## Applies to

- [`RedisResource`](/reference/api/go/aspire.hosting.redis/redisresource.md)
