RedisBuilderExtensions.WithPersistence Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Configures a Redis container resource for persistence.
public static Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.RedisResource> WithPersistence (this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.RedisResource> builder, TimeSpan? interval = default, long keysChangedThreshold = 1);
static member WithPersistence : Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.RedisResource> * Nullable<TimeSpan> * int64 -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.RedisResource>
<Extension()>
Public Function WithPersistence (builder As IResourceBuilder(Of RedisResource), Optional interval As Nullable(Of TimeSpan) = Nothing, Optional keysChangedThreshold As Long = 1) As IResourceBuilder(Of RedisResource)
Parameters
- builder
- IResourceBuilder<RedisResource>
The resource builder.
- keysChangedThreshold
- Int64
The number of key change operations required to trigger a snapshot at the interval. Defaults to 1.
Returns
The IResourceBuilder<T>.
Remarks
Use with WithDataBindMount(IResourceBuilder<RedisResource>, String, Boolean) or WithDataVolume(IResourceBuilder<RedisResource>, String, Boolean) to persist Redis data across sessions with custom persistence configuration, e.g.:
var cache = builder.AddRedis("cache")
.WithDataVolume()
.WithPersistence(TimeSpan.FromSeconds(10), 5);