-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Add AddStackExchangeRedisCache
& AddHsts
overload
#40689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
#nullable enable | ||
static Microsoft.Extensions.DependencyInjection.StackExchangeRedisCacheServiceCollectionExtensions.AddStackExchangeRedisCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection! |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
using System; | ||
using Microsoft.Extensions.Caching.Distributed; | ||
using Microsoft.Extensions.Caching.StackExchangeRedis; | ||
using Microsoft.Extensions.DependencyInjection.Extensions; | ||
|
||
namespace Microsoft.Extensions.DependencyInjection; | ||
|
||
|
@@ -12,6 +13,25 @@ namespace Microsoft.Extensions.DependencyInjection; | |
/// </summary> | ||
public static class StackExchangeRedisCacheServiceCollectionExtensions | ||
{ | ||
/// <summary> | ||
/// Adds Redis distributed caching services to the specified <see cref="IServiceCollection" />. | ||
/// </summary> | ||
/// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param> | ||
/// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns> | ||
public static IServiceCollection AddStackExchangeRedisCache(this IServiceCollection services) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can redis be used with only default settings? I doesn't look like it. This overload shouldn't exist if settings are required. |
||
{ | ||
if (services == null) | ||
{ | ||
throw new ArgumentNullException(nameof(services)); | ||
} | ||
|
||
services.AddOptions(); | ||
|
||
services.TryAdd(ServiceDescriptor.Singleton<IDistributedCache, RedisCache>()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did this change from Add to TryAdd? It breaks a test and is a behavioral change |
||
|
||
return services; | ||
} | ||
|
||
/// <summary> | ||
/// Adds Redis distributed caching services to the specified <see cref="IServiceCollection" />. | ||
/// </summary> | ||
|
@@ -31,9 +51,8 @@ public static IServiceCollection AddStackExchangeRedisCache(this IServiceCollect | |
throw new ArgumentNullException(nameof(setupAction)); | ||
} | ||
|
||
services.AddOptions(); | ||
services.AddStackExchangeRedisCache(); | ||
services.Configure(setupAction); | ||
services.Add(ServiceDescriptor.Singleton<IDistributedCache, RedisCache>()); | ||
|
||
return services; | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.