What is the correct way to maintain the ConnectionMultiplexer object in StackExchange.Redis?

I am storing a static object ConnectionMultiplexer

in an ASP.NET MVC website, getting ~ 500req / sec which ends up in a Redis instance on RedisLabs. From time to time I see errors saying SocketFailure on EVAL

and increasing the number of connections in the RedisLabs dashboard. Should I delete the old instance ConnectionMultiplexer

and recreate the new one, or try to manually reconnect after these exceptions?

+3


source to share


1 answer


The system should try to reconnect automatically. What it doesn't do is rerun your commands, because it doesn't know what it did or fill out on the server (because: socket failed, since everyone knows it, the "ok" response could have been sent by redis).



This way you don't need to host / reconnect. You can monitor connection failure / reconnection through events published to the multiplexer instance. You can also use the method .IsConnected()

on the database (this requires a key for server targeting purposes, but if you're only talking to one server, you can pass anything as the key).

+2


source







All Articles