次の方法で共有


RedisBuilderExtensions.WithDataVolume Method

Definition

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

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

Parameters

builder
IResourceBuilder<RedisResource>

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 Redis persistence.
Defaults to false.

Returns

The IResourceBuilder<T>.

Remarks

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

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

Applies to