I am curious why ConnectionMultiplexer.Connect(options)
attempts to connect 2 clients to the RedisDB instead of 1? Each time I connect I see that 2 additional clients connect to my RedisDB.
Redis is the ConnectionMultiplexer class in the StackExchange. Redis namespace; this is the object that hides away the details of multiple servers. Because the ConnectionMultiplexer does a lot, it is designed to be shared and reused between callers. You should not create a ConnectionMultiplexer per operation.
It uses Lazy<T> to handle thread-safe initialization. It sets "abortConnect=false", which means if the initial connect attempt fails, the ConnectionMultiplexer will silently retry in the background rather than throw an exception.
The ConnectionMultiplexer is the main arbiter of the connection to Redis inside the CLR, your application should maintain a single instance of the ConnectionMultiplexer throughout its runtime. You can initialize the Multiplexer with either a connection string, or with a ConfigurationOptions object.
Overview. StackExchange. Redis is a high performance general purpose redis client for . NET languages (C#, etc.). It is the logical successor to BookSleeve, and is the client developed-by (and used-by) Stack Exchange for busy sites like Stack Overflow.
Because redis requires separate connections for interactive commands versus pub/sub subscriptions. If you aren't using pub/sub, you could tell the options to disable the SUBSCRIBE
command, in which case I believe the second connection is not established.
You can turn off second connection if you don't use redis pub/sub
var config = ConfigurationOptions.Parse(redisConnectionString);
config.CommandMap = CommandMap.Create(new HashSet<string> { "SUBSCRIBE" }, false);
connection = ConnectionMultiplexer.Connect(config);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With