[RedisCache] Add a IServiceProvider parameter in AddStackExchangeRedisOutputCache()
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
## Background and Motivation
Since we can [use a factory to instantiate the ConnexionMultiplexer](https://github.com/dotnet/aspnetcore/issues/28379), an additional feature would be to add a IServiceProvider in parameter of `AddStackExchangeRedisOutputCache()`
I know it can be not so obvious because of the method `.Configure()` that doesn't take itself a parameter for the IServiceProvider.
I hope that this will not be an obstacle to the realization of this request.
## Proposed API
```diff
namespace Microsoft.Extensions.DependencyInjection;
public static class StackExchangeRedisOutputCacheServiceCollectionExtensions
{
public static IServiceCollection AddStackExchangeRedisOutputCache(this IServiceCollection services, Action setupAction)
{
ArgumentNullThrowHelper.ThrowIfNull(services);
ArgumentNullThrowHelper.ThrowIfNull(setupAction);
services.AddOptions();
services.Configure(setupAction);
services.AddSingleton();
return services;
}
+ public static IServiceCollection AddStackExchangeRedisOutputCache(this IServiceCollection services, Action setupAction)
+ {
+ ...
+ }
}
```
## Usage Examples
```csharp
services.AddStackExchangeRedisOutputCache(
(sp, options) =>
{
options.ConnectionMultiplexerFactory = () => Task.FromResult(sp.GetRequiredService());
}
```
Contributor guide
Assessment
This issue has not been assessed yet.