extensions icon indicating copy to clipboard operation
extensions copied to clipboard

[API Proposal]: Register multiple HybridCache objects

Open cesarbmx opened this issue 7 months ago • 1 comments

Background and motivation

EXPECTED We would like to manually register multiple HybridCaches and have control on how to resolve the IDistributedCache

GOAL We use different keyed singleton IDistributedCache objects in our code We want to have as many HybridCaches as IDistributedCache implementations

API Proposal

 services.AddSingleton(x =>
 {
     var options = new HybridCacheOptions
     {      
         DistributedCache = sp.GetRequiredService<MyFirstDistributedCache>());
     };
     return new MyFirstHybridCache(options);
 });

 services.AddSingleton(x =>
 {
     var options = new HybridCacheOptions
     {      
         DistributedCache = sp.GetRequiredService<MySecondDistributedCache>());
     };
     return new MySecondHybridCache(options);
 });

API Usage

.

Alternative Designs

No response

Risks

No response

cesarbmx avatar May 16 '25 16:05 cesarbmx