Search code examples
c#asp.net-mvcredisstackexchange.redisstackexchange

Where is the correct place to store ConnectionMultiplexer in stackexchange redis


Is there a potential issue with storing it as a static variable in my utilities and accessing it anywhere or should using statements be used?

I'm assuming the latter, much like a data context but if it's more efficient to use the initial, since I want the connection to pretty much always be open I'd just like to draw on others experience.

Thanks


Solution

  • I am storing multiplexer in static variable and did not ancountered any problem. Based on creators document https://github.com/StackExchange/StackExchange.Redis/blob/master/Docs/Basics.md it is not recommended to use using statement cause multiplexer designed to be reused. Find it in beggining of the document. Hope it will help.