79694889

Date: 2025-07-08 22:33:23
Score: 1
Natty:
Report link

.NET now has keyed services:

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-9.0#keyed-services

.e.g

builder.Services.AddKeyedSingleton<ICache, BigCache>("big");
builder.Services.AddKeyedSingleton<ICache, SmallCache>("small");

var app = builder.Build();

app.MapGet("/big", ([FromKeyedServices("big")] ICache bigCache) => ... app.MapGet("/small", ([FromKeyedServices("small")] ICache smallCache) => ...
                                                               
Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Jevon Kendon