GarnetBuilderExtensions.WithDataVolume 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.
Adds a named volume for the data folder to a Garnet container resource and enables Garnet persistence.
public static Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.GarnetResource> WithDataVolume (this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.GarnetResource> builder, string? name = default, bool isReadOnly = false);
static member WithDataVolume : Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.GarnetResource> * string * bool -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.GarnetResource>
<Extension()>
Public Function WithDataVolume (builder As IResourceBuilder(Of GarnetResource), Optional name As String = Nothing, Optional isReadOnly As Boolean = false) As IResourceBuilder(Of GarnetResource)
Parameters
- builder
- IResourceBuilder<GarnetResource>
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 Garnet persistence.
Defaults to false
.
Returns
The IResourceBuilder<T>.
Examples
Use WithPersistence(IResourceBuilder<GarnetResource>, Nullable<TimeSpan>, Int64) to adjust Garnet persistence configuration, e.g.:
var cache = builder.AddGarnet("cache")
.WithDataVolume()
.WithPersistence(TimeSpan.FromSeconds(10), 5);