gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 09:53:25 27 4
gpt4 key购买 nike

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/

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