StackExchange.Redis ConnectionMultiplexer life cycle management in web scenario
Asked Answered
C

1

6

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?

Changeable answered 14/9, 2014 at 10:28 Comment(0)
C
8

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)

Companionate answered 14/9, 2014 at 12:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.