MongoDB\Driver\WriteConcern::__construct — Construct immutable WriteConcern
Creates a new WriteConcern.
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.|
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.
|0||Block indefinitely. This is the default.|
|<Greater than 0>||Milliseconds to wait until returning.|
Wait until mongod has applied the write to the journal.
Wait until the write has been flushed to disk.
Cannot be used with
This option should be discouraged.
Пример #1 MongoDB\Driver\WriteConcern::__construct() example
/* Request Write Confirmation from majority of the Replica Set nodes */
$wc = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 500);
/* Request Write Confirmation configured by the "MultipleDC" tag */
$wc = new MongoDB\Driver\WriteConcern("MultipleDC", 500);
Результатом выполнения данного примера будет что-то подобное: