バージョン1.5の新機能。
定義
Return Values
配列またはオブジェクト、またはキャッシュされた再開トークンがない場合はnull 。 戻り値の型は、変更ストリームの作成に使用されるwatch()メソッドのtypeMapオプションによって異なります。
例
この例では、 invalidateイベントが発生した後の変更ストリームの再開トークンをキャプチャし、それを使用して 2 つ目の変更ストリームを構築し、 startAfterオプションを使用して 2 つ目の変更ストリームを構築します。
$uri = 'mongodb://rs1.example.com,rs2.example.com/?replicaSet=myReplicaSet';
$collection = (new MongoDB\Client($uri))->test->inventory;
$changeStream = $collection->watch();
for ($changeStream->rewind(); true; $changeStream->next()) { if ( ! $changeStream->valid()) { continue; }
$event = $changeStream->current();
if ($event['operationType'] === 'invalidate') { $startAfter = $changeStream->getResumeToken(); break; }
printf("%d: %s\n", $changeStream->key(), $event['operationType']);}
$changeStream = $collection->watch([], ['startAfter' => $startAfter]);その他の参照
MongoDB マニュアルの「変更ストリームの再開」に関するドキュメント