gpt4 book ai didi

c# - 如何断开 mongodb(.net 驱动程序 2.0)

转载 作者:太空宇宙 更新时间:2023-11-03 23:36:22 29 4
gpt4 key购买 nike

旧 API,我可以断开 mongodb 服务器。

MongoClient client = new MongoClient(connectionString);
.
.
.
client.GetServer().Disconnect();

但是新 API,GetServer() 已过期。和异步问题...是否需要断开 mongodb 服务器?

最佳答案

您不应该断开与 mongodb 服务器的连接,因为连接由连接池管理。

Creating new authenticated connections to the database is expensive. So, instead of creating and destroying connections for each request to the database, you want to re-use existing connections as much as possible. This is where connection pooling comes in. http://blog.mongolab.com/2013/11/deep-dive-into-connection-pooling/

关于c# - 如何断开 mongodb(.net 驱动程序 2.0),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30425952/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com