Skip to content

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

Closed
wants to merge 4 commits into from

Conversation

ShreyasJejurkar
Copy link
Contributor

Contributes to #39251

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Mar 14, 2022
@ShreyasJejurkar ShreyasJejurkar changed the title Add AddStackExchangeRedisCache overload Add AddStackExchangeRedisCache & AddHsts overload Mar 14, 2022
@ShreyasJejurkar ShreyasJejurkar marked this pull request as ready for review March 14, 2022 13:57
@mkArtakMSFT mkArtakMSFT added the old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels label Mar 14, 2022
Copy link
Member

@BrennanConroy BrennanConroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BrennanConroy
Copy link
Member

Ping @ShreyasJejurkar, this is almost done just needs a minor update!

@ShreyasJejurkar
Copy link
Contributor Author

Hi @BrennanConroy, I will finish this tomorrow most likely. Sorry for the delay, last week I was busy with my office stuff! 🙁

@ShreyasJejurkar ShreyasJejurkar marked this pull request as draft April 6, 2022 06:33
@BrennanConroy
Copy link
Member

Friendly ping.

I can finish it for you if it's still in-process by next week, deal?

Adds test to conver new extension method.
@ShreyasJejurkar ShreyasJejurkar marked this pull request as ready for review April 14, 2022 07:08

services.AddOptions();

services.TryAdd(ServiceDescriptor.Singleton<IDistributedCache, RedisCache>());
Copy link
Member

Choose a reason for hiding this comment

The 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

/// </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)
Copy link
Member

Choose a reason for hiding this comment

The 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.

@halter73
Copy link
Member

halter73 commented May 5, 2022

How common is it to not use the AddStackExchangeRedisCache configuration callback? Is binding config to RedisCacheOptions a thing people do? Unlike AddHsts(), there's some value in just adding the redis cache services without the options configuration callback. And we have the equivalent non-callback overload in SignalR.StackExchangeRedis FWIW.

However, I do worry like @Tratcher that this could confuse the majority who don't know how to configure options without the AddStackExchangeRedisCache callback. I know we're not removing the existing overload, but even the presence of an overload without the callback does kinda imply that the services are usable without custom configuration. I guess it should be obvious that can't be the case for something like redis unless people are expecting some sort of dev instance to automatically be launched.

While I agree with @RehanSaeed's comment on the issue,

Yes, at the moment it's pretty strange to be forced to pass an empty delegate:

services.AddStackExchangeRedisCache(x => {});

Assuming this is a pretty uncommon use case, it does work exactly the same as this new overload. I think the slight strangeness in the rare case may be a fair price to pay to eliminate overloads most developers wouldn't know how to use.

Sorry @ShreyasJejurkar. We really appreciate the contributions. Don't close this yet just based on my feedback. I going to re-add the ready-for-review to the original issue. The new proposal will include only the AddStackExchangeRedisCache overload so we can discuss it Monday. We may or may not decide to reject the API.

@BrennanConroy
Copy link
Member

API review rejected the new API see #39251 (comment). Thanks for the contribution though, sorry we couldn't take it 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Indicates that the PR has been added by a community member old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants