MongoDB::setWriteConcern
(PECL mongo >=1.5.0)
MongoDB::setWriteConcern — Set the write concern for this database
説明
public MongoDB::setWriteConcern
( mixed $w
[, int $wtimeout
] ) : bool
パラメータ
w
- 書き込み確認。何台のサーバーに書き込めたら成功とみなすのかを表す整数値、あるいは文字列 ("majority" など) でモードを指定します。
wtimeout
- サーバーが書き込み確認を待つ最大ミリ秒数。
返り値
成功した場合に true
、それ以外の場合に false
を返します。
エラー / 例外
w
が整数値あるいは文字列でない場合に E_WARNING
が発生します。
例
例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);?>
参考
- The write concern documentation.
- MongoDB::getWriteConcern() - Get the write concern for this database