# withPersistence

- Module: [Aspire.Hosting.Valkey](/reference/api/typescript/aspire.hosting.valkey.md)
- Version: `13.4.0`
- Kind: `method`
- Source: [GitHub](https://github.com/microsoft/aspire)

Configures a Valkey container resource for persistence.

## Definition

```typescript
interface ValkeyResource {
  // ... omitted for brevity
  withPersistence(
    interval?: timespan,
    keysChangedThreshold?: number): ValkeyResource
}
```

## Parameters

- `interval` (`timespan`) `optional`
- `keysChangedThreshold` (`number`) `optional` `= 1`

## Returns

[ValkeyResource](/reference/api/typescript/aspire.hosting.valkey/valkeyresource.md) `builder`

## Applies to

- [ValkeyResource](/reference/api/typescript/aspire.hosting.valkey/valkeyresource.md)
