Provides extension methods and resource definitions for a .NET Aspire AppHost to configure a Memcached resource.
In your AppHost project, install the .NET Aspire Memcached Hosting library with NuGet:
dotnet add package Aspire.Hosting.Memcached
Then, in the Program.cs file of AppHost, add a Memcached resource and consume the connection using the following methods:
var Memcached = builder.AddMemcached("Memcached");
var myService = builder.AddProject<Projects.MyService>()
.WithReference(Memcached);You can customize the Memcached resource with optional parameters such as specifying a custom port, memory limits, and maximum item size:
var memcached = builder.AddMemcached(
name: "CustomMemcached",
port: 11212, // Custom host port
maxMemory: 128, // Maximum memory size in MB
maxSizePerItem: 20 // Maximum memory size per item in MB
);
var myService = builder.AddProject<Projects.MyService>()
.WithReference(memcached);