# WithDataVolume

- Module: [Aspire.Hosting.Garnet](/reference/api/go/aspire.hosting.garnet.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: [`GarnetResource`](/reference/api/go/aspire.hosting.garnet/garnetresource.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/2d325b13709752ba6d9a943635c5e2940a2530c0)

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

## Definition

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

## 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 Garnet persistence. Defaults to `false`.

## Returns

[`GarnetResource`](/reference/api/go/aspire.hosting.garnet/garnetresource.md) -- The resource builder.

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

## Applies to

- [`GarnetResource`](/reference/api/go/aspire.hosting.garnet/garnetresource.md)
