var builder = WebApplication.CreateBuilder(args); builder.Services.AddKeyedSingleton("big"); builder.Services.AddKeyedSingleton("small"); builder.Services.AddControllers(); var app = builder.Build(); app.MapGet("/", ([FromKeyedServices("big")] ICache bigCache) => bigCache.Get("date")); app.MapGet("/small", ([FromKeyedServices("small")] ICache smallCache) => smallCache.Get("date")); app.MapControllers(); app.Run();