-
Notifications
You must be signed in to change notification settings - Fork 841
Support keyed HybridCache with keyed DistributedCaches and named options #6694
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
Conversation
e3ee41e to
7726666
Compare
|
I've marked this PR as a draft as we need to get [Support detect keyed dependency injected IDistributedCache as backend cache for DefaultHybridCache (#117976)](dotnet/runtime#117976) through API review, and tests would need to be added to the PR as well. I'm getting a .NET 10 RC1/RC2 bar check for this. I'll keep you posted, @ylt1534. |
3e79448 to
fe9f5e9
Compare
d4f6ecd to
c4417a2
Compare
This comment was marked as resolved.
This comment was marked as resolved.
096297e to
d8581f0
Compare
d3effff to
a123285
Compare
|
Thanks @jeffhandley for the review. I just noticed that the DefaultHybridCache is designed as internal thus unable to DI is outside the lib. I added a new extension method and add some UTs. I want to test that the keyed instances (options, backend cache, memory cache, hybrid cache) are injected into each other correctly, but that might bring more changes like expose the _backendCache and _localCache properties from DefaultHybridCache. For now I tried to make the PR small to be easy review. thanks. |
src/Libraries/Microsoft.Extensions.Caching.Hybrid/HybridCacheServiceExtensions.cs
Outdated
Show resolved
Hide resolved
|
Is this going to be an issue? internal override bool IsHybridCacheActive()
=> _services.GetService<HybridCache>() is not null;this code assumes that if there is an unkeyed |
|
@eerhardt and I discussed the |
Closes dotnet/runtime#117976
Adds support for keyed
HybridCacheinstances in DI, along with the ability to configure theDistributedCacheServiceKeyfor the hybrid cache to resolve a keyedIDistributedCacheservice. This opens up the scenario of having multiple hybrid caches within an application, each potentially using a separate backend cache. Those backend caches could be separate databases or entirely separate services. For example, having a Redis-backed cache alongside a SQL Server-backed cache.Microsoft Reviewers: Open in CodeFlow