略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: MongoDB::setWriteConcern

2024-12-22

MongoDB::setWriteConcern

(PECL mongo >=1.5.0)

MongoDB::setWriteConcernSet the write concern for this database

说明

public MongoDB::setWriteConcern ( mixed $w [, int $wtimeout ] ) : bool

参数

w

The write concern. This may be an integer denoting the number of servers required to acknowledge the write, or a string mode (e.g. "majority").

wtimeout

The maximum number of milliseconds to wait for the server to satisfy the write concern.

返回值

Returns TRUE on success, or FALSE otherwise.

错误/异常

Emits E_WARNING if the w parameter is not an integer or string value.

范例

Example #1 MongoDB::setWriteConcern() example

<?php

$mc 
= new MongoClient('mongodb://rs1.example.com,rs2.example.com');
$db $mc->selectDB('test');

// Require that the majority of servers in the replica set acknowledge writes
// within three seconds.
$db->setWriteConcern('majority'3000);
?>

参见

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/mongodb.setwriteconcern.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3