MongoDB\Driver\WriteConcern::__construct

(mongodb >=1.0.0)

MongoDB\Driver\WriteConcern::__constructConstruct immutable WriteConcern

Опис

final public MongoDB\Driver\WriteConcern::__construct ( string $wstring [, integer $wtimeout [, boolean $journal [, boolean $fsync ]]] )

Creates a new WriteConcern.

Параметри

wstring

Write Concern
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.

Write Concern timeout
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.

Зауваження:

Cannot be used with journal.

Зауваження:

This option should be discouraged.

Помилки/Винятки

Приклади

Приклад #1 MongoDB\Driver\WriteConcern::__construct() example

<?php
/* Request Write Confirmation from majority of the Replica Set nodes */
$wc = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY500);

/* Request Write Confirmation configured by the "MultipleDC" tag */
$wc = new MongoDB\Driver\WriteConcern("MultipleDC"500);
?>

Наведений вище приклад виведе щось подібне до:

Прогляньте Також

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top