AspireRedisDistributedCacheExtensions.AddRedisDistributedCache Method

Definition

Adds Redis distributed caching services, IDistributedCache, in the services provided by the builder.

C#
public static void AddRedisDistributedCache(this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, string connectionName, Action<Aspire.StackExchange.Redis.StackExchangeRedisSettings>? configureSettings = default, Action<StackExchange.Redis.ConfigurationOptions>? configureOptions = default);

Parameters

builder
IHostApplicationBuilder

The IHostApplicationBuilder to read config from and add services to.

connectionName
String

A name used to retrieve the connection string from the ConnectionStrings configuration section.

configureSettings
Action<StackExchangeRedisSettings>

An optional method that can be used for customizing the StackExchangeRedisSettings. It's invoked after the settings are read from the configuration.

configureOptions
Action<StackExchange.Redis.ConfigurationOptions>

An optional method that can be used for customizing the StackExchange.Redis.ConfigurationOptions. It's invoked after the options are read from the configuration.

Remarks

Reads the configuration from "Aspire:StackExchange:Redis" section.

Also registers StackExchange.Redis.IConnectionMultiplexer as a singleton in the services provided by the builder. Enables retries, corresponding health check, logging, and telemetry.

Applies to

Produto Versões
.NET Aspire 8.0.0, 9.0.0, 9.1.0