コンテンツにスキップ
Docs Try Aspire
Docs Try

Get started with Redis output caching

このコンテンツはまだ日本語訳がありません。

Redis logo

The Redis® output caching integration is the [OutputCache]-flavored layer over the Redis hosting integration. It registers an ASP.NET Core Output Caching store backed by Redis using the Aspire.StackExchange.Redis.OutputCaching package — so your controllers and minimal API endpoints can use [OutputCache] or services.AddOutputCache() without any manual connection wiring.

Adding Redis output caching through Aspire gives you:

  • Drop-in IOutputCacheStore implementation. A single AddRedisOutputCache call replaces the default in-memory store with a Redis-backed one that works across app replicas.
  • Automatic registration. Aspire wires up the Redis connection from the AppHost reference — no connection strings to manage by hand.
  • [OutputCache] attribute support. Works with the standard [OutputCache(Duration = 60)] attribute, CacheOutput() extension, and services.AddOutputCache() — no special API needed.
  • Built-in health checks. The client integration registers a health check that verifies the Redis instance is reachable and command-ready.
  • OpenTelemetry telemetry. Logging, distributed tracing, and metrics are configured automatically through OpenTelemetry.

The Redis output caching integration has two sides: a hosting integration that you use in your AppHost to model the Redis resource, and a client integration that the consuming ASP.NET Core app uses to register the output cache store.

architecture-beta

  group apphost(server)[AppHost]
  group consumer(server)[ASP NET Core app]

  service hosting(server)[Hosting integration] in apphost
  service redis(server)[Redis server] in apphost

  service client(iconoir:server-connection)[StackExchange Redis output cache client] in consumer
  service app(server)[App] in consumer

  hosting:R --> L:redis
  redis:R --> L:client
  client:R --> L:app

The hosting integration lives in your AppHost project and models the Redis server as a resource. The client integration lives in your ASP.NET Core project and uses the connection information Aspire injects to register IOutputCacheStore.

Getting there is a two-step process: model the Redis resource in your AppHost, then connect to it from each app that needs output caching.

  1. Add the Redis hosting integration to your AppHost, then declare a Redis resource and reference it from the apps that need it. See Set up Redis output caching in the AppHost for the installation steps and basic resource declaration. For the full AppHost API surface — data volumes, persistence, parameters, Redis Insights, and more — refer to the main Redis Hosting integration.

    Set up Redis output caching in the AppHost

  2. When you reference a Redis resource from a consuming project, Aspire injects its connection information as environment variables. See Connect to Redis output caching for the connection properties reference, the AddRedisOutputCache registration, configuration patterns, health checks, telemetry, and usage examples with [OutputCache].

    Connect to Redis output caching