update : 2015.11.03
php.shukuma.com

검색:
 
 
Construct immutable WriteConcern

MongoDB\Driver\WriteConcern::__construct

(mongodb >=0.2.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.

Note:

Cannot be used with journal.

Note:

This option should be discouraged.

오류/예외

  • Throws MongoDB\Driver\InvalidArgumentException on argument parsing errors.

예제

Example #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);
?>

위 예제의 출력 예시:

참고