# ValkeyResource.WithPersistence

- Module: [Aspire.Hosting.Valkey](/reference/api/go/aspire.hosting.valkey.md)
- Defined on: [ValkeyResource](/reference/api/go/aspire.hosting.valkey/valkeyresource.md)
- Version: `17.0.0`
- Kind: `method`

Configures a Valkey container resource for persistence.

## Definition

```go
type ValkeyResource interface {
    // ... omitted for brevity
    WithPersistence(options ...*WithPersistenceOptions) ValkeyResource
}
```

## Signature

```go
WithPersistence(options ...*WithPersistenceOptions) ValkeyResource
```

## 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

[`ValkeyResource`](/reference/api/go/aspire.hosting.valkey/valkeyresource.md) -- The resource builder.

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

## Defined on

- [ValkeyResource](/reference/api/go/aspire.hosting.valkey/valkeyresource.md) -- `handle`
