Stackexchange.Redis why does ConnectionMultiplexer.Connect establishes two client connections?

五迷三道 提交于 2019-12-10 15:45:57

问题


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.


回答1:


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.




回答2:


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);


来源:https://stackoverflow.com/questions/28145865/stackexchange-redis-why-does-connectionmultiplexer-connect-establishes-two-clien

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!