Skip to content
DocsTry Aspire
DocsTry

AspireRedisExtensions Methods

ClassMethods4 members
Provides extension methods for registering Redis-related services in an Hosting.IHostApplicationBuilder.
AddKeyedRedisClient(IHostApplicationBuilder, string, Action<StackExchangeRedisSettings>, Action<ConfigurationOptions>)Section titled AddKeyedRedisClient(IHostApplicationBuilder, string, Action<StackExchangeRedisSettings>, Action<ConfigurationOptions>)extension
Registers Redis.IConnectionMultiplexer as a keyed singleton for the given name in the services provided by the builder. Enables retries, corresponding health check, logging, and telemetry.
public static class AspireRedisExtensions
{
public static void AddKeyedRedisClient(
this IHostApplicationBuilder builder,
string name,
Action<StackExchangeRedisSettings>? configureSettings = null,
Action<ConfigurationOptions>? configureOptions = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
namestringThe name of the component, which is used as the ServiceDescriptor.ServiceKey of the service and also to retrieve the connection string from the ConnectionStrings configuration section.
configureSettingsAction<StackExchangeRedisSettings>optionalAn optional method that can be used for customizing the StackExchangeRedisSettings. It's invoked after the settings are read from the configuration.
configureOptionsAction<ConfigurationOptions>optionalAn optional method that can be used for customizing the Redis.ConfigurationOptions. It's invoked after the options are read from the configuration.
Reads the configuration from "Aspire:StackExchange:Redis:{name}" section.
AddKeyedRedisClientBuilder(IHostApplicationBuilder, string, Action<StackExchangeRedisSettings>, Action<ConfigurationOptions>)Section titled AddKeyedRedisClientBuilder(IHostApplicationBuilder, string, Action<StackExchangeRedisSettings>, Action<ConfigurationOptions>)extensionAspireRedisClientBuilder
Registers Redis.IConnectionMultiplexer as a keyed singleton for the given name in the services provided by the builder. Enables retries, corresponding health check, logging, and telemetry.
public static class AspireRedisExtensions
{
public static AspireRedisClientBuilder AddKeyedRedisClientBuilder(
this IHostApplicationBuilder builder,
string name,
Action<StackExchangeRedisSettings>? configureSettings = null,
Action<ConfigurationOptions>? configureOptions = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
namestringThe name of the component, which is used as the ServiceDescriptor.ServiceKey of the service and also to retrieve the connection string from the ConnectionStrings configuration section.
configureSettingsAction<StackExchangeRedisSettings>optionalAn optional method that can be used for customizing the StackExchangeRedisSettings. It's invoked after the settings are read from the configuration.
configureOptionsAction<ConfigurationOptions>optionalAn optional method that can be used for customizing the Redis.ConfigurationOptions. It's invoked after the options are read from the configuration.
Reads the configuration from "Aspire:StackExchange:Redis:{name}" section.
AddRedisClient(IHostApplicationBuilder, string, Action<StackExchangeRedisSettings>, Action<ConfigurationOptions>)Section titled AddRedisClient(IHostApplicationBuilder, string, Action<StackExchangeRedisSettings>, Action<ConfigurationOptions>)extension
Registers Redis.IConnectionMultiplexer as a singleton in the services provided by the builder. Enables retries, corresponding health check, logging, and telemetry.
public static class AspireRedisExtensions
{
public static void AddRedisClient(
this IHostApplicationBuilder builder,
string connectionName,
Action<StackExchangeRedisSettings>? configureSettings = null,
Action<ConfigurationOptions>? configureOptions = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
connectionNamestringA name used to retrieve the connection string from the ConnectionStrings configuration section.
configureSettingsAction<StackExchangeRedisSettings>optionalAn optional method that can be used for customizing the StackExchangeRedisSettings. It's invoked after the settings are read from the configuration.
configureOptionsAction<ConfigurationOptions>optionalAn optional method that can be used for customizing the Redis.ConfigurationOptions. It's invoked after the options are read from the configuration.
Reads the configuration from "Aspire:StackExchange:Redis" section.
AddRedisClientBuilder(IHostApplicationBuilder, string, Action<StackExchangeRedisSettings>, Action<ConfigurationOptions>)Section titled AddRedisClientBuilder(IHostApplicationBuilder, string, Action<StackExchangeRedisSettings>, Action<ConfigurationOptions>)extensionAspireRedisClientBuilder
Registers Redis.IConnectionMultiplexer as a singleton in the services provided by the builder. Enables retries, corresponding health check, logging, and telemetry.
public static class AspireRedisExtensions
{
public static AspireRedisClientBuilder AddRedisClientBuilder(
this IHostApplicationBuilder builder,
string connectionName,
Action<StackExchangeRedisSettings>? configureSettings = null,
Action<ConfigurationOptions>? configureOptions = null)
{
// ...
}
}
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder to read config from and add services to.
connectionNamestringA name used to retrieve the connection string from the ConnectionStrings configuration section.
configureSettingsAction<StackExchangeRedisSettings>optionalAn optional method that can be used for customizing the StackExchangeRedisSettings. It's invoked after the settings are read from the configuration.
configureOptionsAction<ConfigurationOptions>optionalAn optional method that can be used for customizing the Redis.ConfigurationOptions. It's invoked after the options are read from the configuration.
Reads the configuration from "Aspire:StackExchange:Redis" section.