0

我正在将我的 mongodb c++ 客户端代码从旧版驱动程序和 26compat 驱动程序升级到 r3.0.2 驱动程序。现在删除了作用域连接池类。我的问题是如何使用连接池连接到副本集。我目前的代码是:

 //only call it once in my app
 mongocxx::instance inst{};
 //call it in anywhere I need 
 mongocxx::client conn{mongocxx::uri{mongodb://i-e6ql0k8k,i-exiv5yox,i-sfdxzsjr/?replicaSet=rs1}};

使用默认的最大池大小 100 值。但我不知道我的方式是否正确?

4

1 回答 1

1

你会想要使用mongocxx::pool类。URI 看起来不错——只要您有replicaSet选项,驱动程序就会理解以副本集模式进行连接。

于 2016-11-16T14:19:51.283 回答