次の方法で共有


ValkeyBuilderExtensions.WithPersistence Method

Definition

Configures a Valkey container resource for persistence.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ValkeyResource> WithPersistence (this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ValkeyResource> builder, TimeSpan? interval = default, long keysChangedThreshold = 1);
static member WithPersistence : Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ValkeyResource> * Nullable<TimeSpan> * int64 -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ValkeyResource>
<Extension()>
Public Function WithPersistence (builder As IResourceBuilder(Of ValkeyResource), Optional interval As Nullable(Of TimeSpan) = Nothing, Optional keysChangedThreshold As Long = 1) As IResourceBuilder(Of ValkeyResource)

Parameters

builder
IResourceBuilder<ValkeyResource>

The resource builder.

interval
Nullable<TimeSpan>

The interval between snapshot exports. Defaults to 60 seconds.

keysChangedThreshold
Int64

The number of key change operations required to trigger a snapshot at the interval. Defaults to 1.

Returns

The IResourceBuilder<T>.

Examples

Use with WithDataBindMount(IResourceBuilder<ValkeyResource>, String, Boolean) or WithDataVolume(IResourceBuilder<ValkeyResource>, String, Boolean) to persist Valkey data across sessions with custom persistence configuration, e.g.:

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

Applies to