Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StackExchange.Redis ConnectionMultiplexer life cycle management in web scenario

What is the correct lifecycle management of the ConnectionMultiplexer instance in a web scenario. As I understand it manages individual requests by pipelining them and thus reduces the negative effect caused by latency. Does that mean that in a web application the ConnectionMultiplexer should be used as a singleton as opposed to the more frequently used request scope?

like image 628
neo112 Avatar asked Sep 14 '14 10:09

neo112


1 Answers

Essentially, yes - you should rarely need more than one multiplexer to the same Redis nodes. This is also described here. Note that the database object from GetDatabase is very cheap, and can be per request or per method-scope if needed (per-rewuest plays very nicely for multi-tenancy scenarios where different tenants are on different database numbers)

like image 191
Marc Gravell Avatar answered Sep 22 '22 06:09

Marc Gravell