using Microsoft.AspNetCore.SignalR; var builder = WebApplication.CreateBuilder(args); builder.Services.AddKeyedSingleton("big"); builder.Services.AddKeyedSingleton("small"); builder.Services.AddRazorPages(); builder.Services.AddSignalR(); var app = builder.Build(); app.MapRazorPages(); app.MapHub("/myHub"); app.Run(); public interface ICache { object Get(string key); } public class BigCache : ICache { public object Get(string key) => $"Resolving {key} from big cache."; } public class SmallCache : ICache { public object Get(string key) => $"Resolving {key} from small cache."; } public class MyHub : Hub { public void SmallCacheMethod([FromKeyedServices("small")] ICache cache) { Console.WriteLine(cache.Get("signalr")); } public void BigCacheMethod([FromKeyedServices("big")] ICache cache) { Console.WriteLine(cache.Get("signalr")); } }