# WithDataVolume

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

Adds a named volume for the data folder to a Redis container resource and enables Redis persistence.

## Definition

```go
func (RedisResource) WithDataVolume(options ...*WithDataVolumeOptions) RedisResource
```

## Parameters

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

## Options

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

- `Name` (`*string`) -- The name of the volume. Defaults to an auto-generated name based on the application and resource names.
- `IsReadOnly` (`*bool`) -- A flag that indicates if this is a read-only volume. Setting this to `true` will disable Redis persistence. Defaults to `false`.

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