Stackexchange.Redis why does ConnectionMultiplexer

2019-06-25 22:32发布

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.

2条回答
女痞
2楼-- · 2019-06-25 23:25

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);
查看更多
冷血范
3楼-- · 2019-06-25 23:35

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.

查看更多
登录 后发表回答