# Set up Redis output caching in the AppHost

<Image
  src={redisIcon}
  alt="Redis logo"
  width={100}
  height={100}
  class:list={'float-inline-left icon'}
  data-zoom-off
/>

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](/integrations/caching/redis/redis-host/) reference.

If you're new to the Redis output caching integration, start with [Get started with Redis output caching](/integrations/caching/redis-output/redis-output-get-started/). For how consuming ASP.NET Core apps register the output cache store and use `[OutputCache]`, see [Connect to Redis output caching](../redis-output-connect/).

## Installation

Install the [📦 Aspire.Hosting.Redis](https://www.nuget.org/packages/Aspire.Hosting.Redis) NuGet package in your AppHost project:

```bash title="Terminal"
aspire add redis
```

<LearnMore>
  Learn more about [`aspire add`](/reference/cli/commands/aspire-add/) in the command reference.
</LearnMore>

Or, choose a manual installation approach:

```csharp title="C# — AppHost.cs"
#:package Aspire.Hosting.Redis@*
```

```xml title="XML — AppHost.csproj"
<PackageReference Include="Aspire.Hosting.Redis" Version="*" />
```

```bash title="Terminal"
aspire add redis
```

<LearnMore>
  Learn more about [`aspire add`](/reference/cli/commands/aspire-add/) in the command reference.
</LearnMore>

This updates your `aspire.config.json` with the Redis hosting integration package:

```json title="aspire.config.json" ins={3}
{
  "packages": {
    "Aspire.Hosting.Redis": "*"
  }
}
```

## Add Redis resource

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

```csharp title="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...
```

```typescript title="TypeScript — apphost.mts"
import { createBuilder } from './.aspire/modules/aspire.mjs';

const builder = await createBuilder();

const cache = await builder.addRedis("cache");

await builder.addProject("apiservice", "../ApiService/ApiService.csproj")
    .withReference(cache);

// After adding all resources, run the app...
```
**Note:** When you reference the Redis resource from the AppHost, Aspire injects connection properties — host, port, password, and URI — as environment variables into the consuming project. For the full list and how to read them in C#, see [Connect to Redis output caching](../redis-output-connect/#connection-properties).

## More AppHost options

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](/integrations/caching/redis/redis-host/) reference.

:::tip[Registered trademark]{icon="information"}

<span id="registered-trademark"></span>
Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to
Redis Ltd. Any use by Microsoft is for referential purposes only and does not
indicate any sponsorship, endorsement or affiliation between Redis and
Microsoft.

:::