I read that to connect to the Azure Redis cache it is best to follow this practice:
private static ConnectionMultiplexer Connection { get { return LazyConnection.Value; } } private static readonly Lazy<ConnectionMultiplexer> LazyConnection = new Lazy<ConnectionMultiplexer>( () => { return ConnectionMultiplexer.Connect(connStinrg); });
And according to Azure Redis docs:
The connection to the Azure Redis cache is controlled by the ConnectionMultiplexer class. This class is intended to be shared and reused in your client application, and it does not need to be created based on each operation.
So what is the best way to use ConnectionMultiplexer in my ASP.net MVC application? Should it be called in Global.asax, or should I initialize it once to the controller or smth. else?
I also have a service that is instructed to communicate with the application, so if I want to communicate with Redis inside the Service, should I send an instance of ConnectionMultiplexer for service from the controllers or initialize it in all my services or?
As you can see, I got a little lost here, so please help!
c # asp.net-mvc redis stackexchange.redis azure-redis-cache
hyperN
source share