次の方法で共有


ValkeyBuilderExtensions.WithDataVolume Method

Definition

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

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ValkeyResource> WithDataVolume (this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ValkeyResource> builder, string? name = default, bool isReadOnly = false);
static member WithDataVolume : Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ValkeyResource> * string * bool -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ValkeyResource>
<Extension()>
Public Function WithDataVolume (builder As IResourceBuilder(Of ValkeyResource), Optional name As String = Nothing, Optional isReadOnly As Boolean = false) As IResourceBuilder(Of ValkeyResource)

Parameters

builder
IResourceBuilder<ValkeyResource>

The resource builder.

name
String

The name of the volume. Defaults to an auto-generated name based on the application and resource names.

isReadOnly
Boolean

A flag that indicates if this is a read-only volume. Setting this to true will disable Valkey persistence.
Defaults to false.

Returns

The IResourceBuilder<T>.

Examples

Use WithPersistence(IResourceBuilder<ValkeyResource>, Nullable<TimeSpan>, Int64) to adjust Valkey persistence configuration, e.g.:

var cache = builder.AddValkey("cache")
                   .WithDataVolume()
                   .WithPersistence(TimeSpan.FromSeconds(10), 5);

Applies to