Skip to content
Docs Try Aspire
Docs Try

Set up Redis output caching in the AppHost

Redis logo

This article covers the AppHost setup required for the Redis output caching integration. The underlying resource is the standard Redis hosting integration — for the complete AppHost API surface (data volumes, data bind mounts, persistence, parameters, Redis Insights, Redis Commander, and more), see the Redis Hosting integration reference.

If you’re new to the Redis output caching integration, start with Get started with Redis output caching. For how consuming ASP.NET Core apps register the output cache store and use [OutputCache], see Connect to Redis output caching.

Install the 📦 Aspire.Hosting.Redis NuGet package in your AppHost project:

Terminal
aspire add redis

Learn more about aspire add in the command reference.

Or, choose a manual installation approach:

C# — AppHost.cs
#:package Aspire.Hosting.Redis@*
XML — AppHost.csproj
<PackageReference Include="Aspire.Hosting.Redis" Version="*" />

Once you’ve installed the hosting integration, add a Redis resource and reference it from the consuming ASP.NET Core project:

C# — AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var cache = builder.AddRedis("cache");
var apiService = builder.AddProject<Projects.ApiService>("apiservice")
.WithReference(cache);
// After adding all resources, run the app...

For everything beyond the basic resource declaration — data volumes, data bind mounts, persistence snapshots, custom parameters, Redis Insights, Redis Commander, and connecting to an existing Redis instance — see the Redis Hosting integration reference.