草庐IT

php - PHP Mongo 问题列表 : What does _construct return when replicaSet is true?

coder 2023-10-31 原文

PHP manual ,它有这个例子:

<?php

// pass a comma-separated list of server names to the constructor
$m1 = new Mongo("mongodb://sf2.example.com,ny1.example.com", array("replicaSet" => true));

// you only need to pass a single seed, the driver will derive the full list and
// find the master from this seed
$m2 = new Mongo("mongodb://ny1.example.com", array("replicaSet" => true));

?>
  1. 但是,$m1 返回什么?
  2. 如果我想找出主节点并进行复制,以便主节点负责写入,而其中一个副本负责读取连接,那么我应该找出并应该做什么的最佳方式是什么?
  3. 我能否拥有不同于每个副本的持久值?或者他们必须共享相同的连接 channel ?

最佳答案

关于 #2 的更多信息:Mongo 类自动确定谁是主节点和从节点,然后向主节点发送写入(如果您设置了 slaveOkay,则向从节点发送读取)。

关于php - PHP Mongo 问题列表 : What does _construct return when replicaSet is true?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5559474/

有关php - PHP Mongo 问题列表 : What does _construct return when replicaSet is true?的更多相关文章

随机推荐