Skip to content
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

FEAT: add 2nd overload for AddEasyCaching() to support IServiceProvider for setupActions #487

Merged
merged 1 commit into from
Sep 8, 2023
Merged

FEAT: add 2nd overload for AddEasyCaching() to support IServiceProvider for setupActions #487

merged 1 commit into from
Sep 8, 2023

Conversation

MoienTajik
Copy link
Contributor

@MoienTajik MoienTajik commented Sep 7, 2023

Added 2nd overload for AddEasyCaching() extension method to support IServiceProvider for setupActions.

cc: @catcherwong

@MoienTajik MoienTajik changed the title FEAT: add 2nd overload for AddEasyCaching() to support IServiceProvid… FEAT: add 2nd overload for AddEasyCaching() to support IServiceProvider for setupActions Sep 7, 2023
@catcherwong catcherwong merged commit 790b802 into dotnetcore:dev Sep 8, 2023
3 checks passed
@MoienTajik MoienTajik deleted the feat/sp-in-add-easycaching branch September 8, 2023 06:53
@MoienTajik
Copy link
Contributor Author

Thanks, @catcherwong. I can see one of the tests failed here because of timeout, and probably a retry will fix that. Can we have the new versions available on NuGet today, please? (1.9.1)

@catcherwong
Copy link
Member

@MoienTajik v1.9.1 is available on nuget now.

@artyom-p
Copy link

artyom-p commented Nov 10, 2023

Hey, just installed latest nuget, trying to use that extensions but somethings wrong...

Startup is stuck inside this extension as it goes into recursion and endlessly tries to resolve EasyCachingOptions again and again. Both .AddSingleton are registering the same type factory, and the second one is overriding the first one seems like.

image

Also due to services.AddSingleton<EasyCachingOptions> setup will not start until you will manually try to resolve the options, unlike the overload without IServiceProvider.

@MoienTajik
Copy link
Contributor Author

MoienTajik commented Nov 10, 2023

I was able to reproduce the issue you mentioned. Due to the way EasyCaching registers different implementations of IEasyCachingProvider using IEasyCachingOptionsExtension, the execution of setupAction(sp, options) will be delayed until EasyCachingOptions is manually resolved from DI, which is problematic as it occurs too late.

The first overload functions correctly because it immediately creates and registers EasyCachingOptions and its extensions, rather than using a factory (services.AddSingleton(sp => ...)).

Given the current design of how IEasyCachingOptionsExtension operates, I'm unsure of a solution to this issue. It seems this commit might need to be reverted, as it doesn't behave as intended.

@catcherwong

catcherwong added a commit that referenced this pull request Nov 13, 2023
Signed-off-by: catcherwong <[email protected]>
catcherwong added a commit that referenced this pull request Nov 13, 2023
Signed-off-by: catcherwong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants