0

I have successfully implemented a distributed cache using SQL Server by setting it up as follows:

services.AddDistributedSqlServerCache(options => { options.ConnectionString = Configuration.GetConnectionString("App"); options.SchemaName = "dbo"; options.TableName = "Cache"; }); 

And then I'm injecting it where I need it.

I currently can't upgrade to .NET 9 to implement the new HybridCache. In the meantime I would like to add distributed memory cache as my L1 cache. As both implementations use IDistributedCache per DI, how can I pass both implementations to my consumers?

5
  • You can inject IEnumerable<IDistributedCache> and that will give you both implementations? Commented Jun 9 at 8:42
  • 2
    Time to read the docs: neither Microsoft.Extensions.Caching.Hybrid nor ZiggyCreatures.FusionCache require .NET 9.0; they both target Net Standard 2.0 (and others). Commented Jun 9 at 8:57
  • What Richard said. Source: I'm the main dev for HybridCache Commented Jun 9 at 12:33
  • Adding The HybridCache package also upgrades other packages to (currently) 9.0.5. Isnt this NET9 then? Commented Jun 10 at 4:12
  • There is a difference between requiring .NET 9 (i.e. the entire SDK) and certain packages that happen to be on version 9.x. Adding this package should work on things as far back as Framework 4.6.2 - but if you use old things in the packages that needs to be upgraded you might experience breakages due to that. Commented Jun 10 at 14:02

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.