©
このドキュメントでは、 php中国語ネットマニュアル リリース
(mongodb >=1.0.0)
MongoDB\Driver\WriteConcern::__construct — Construct immutable WriteConcern
$wstring
[, integer $wtimeout
[, boolean $journal
[, boolean $fsync
]]] )Creates a new WriteConcern.
wstring
Value | Description | |
---|---|---|
1 | integer | Provides acknowledgment of write operations on a standalone mongod or the primary in a Replica Set. This is the default value when no Write Concern is provided. |
0 | Disables basic acknowledgment of write operations, but returns information about socket exceptions and networking errors to the application. | |
<Number greater than 1> | Guarantees that write operations have propagated successfully to the specified number of Replica Set members, including the primary. | |
MongoDB\Driver\WriteConcern::MAJORITY | Confirms that write operations have propagated to the majority of configured replica set: a majority of the set’s configured members must acknowledge the write operation before it succeeds. | |
string | A string value as WriteConcern is interpereted as a TagSet value. At least one node in the TagSet must acknowledge the write. |
wtimeout
How long to wait (in milliseconds) for secondaries before failing.
wtimeout causes write operations to return with an error (WriteConcernError) after the specified limit, even if the required write concern will eventually succeed. When these write operations return, MongoDB does not undo successful data modifications performed before the write concern exceeded the wtimeout time limit.
Value | Description |
---|---|
0 | Block indefinitely. This is the default. |
<Greater than 0> | Milliseconds to wait until returning. |
journal
Wait until mongod has applied the write to the journal.
fsync
Wait until the write has been flushed to disk.
Note:
Cannot be used with
journal
.
Note:
This option should be discouraged.
Example #1 MongoDB\Driver\WriteConcern::__construct() example
<?php
$wc = new MongoDB \ Driver \ WriteConcern ( MongoDB \ Driver \ WriteConcern :: MAJORITY , 500 );
$wc = new MongoDB \ Driver \ WriteConcern ( "MultipleDC" , 500 );
?>
以上例程的输出类似于: