PHPマニュアル/PEARマニュアル | ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot

MongoCursor::maxTimeMS - Sets a server-side timeout for this query | JavaScript入門&応用&リファレンスなら「JavaScriptist」

  

MongoCursor::maxTimeMS

(PECL mongo >=1.5.0)

MongoCursor::maxTimeMSSets a server-side timeout for this query

説明

public MongoCursor MongoCursor::maxTimeMS ( int $ms )

Specifies a cumulative time limit in milliseconds to be allowed by the server for processing operations on the cursor.

パラメータ

ms

Specifies a cumulative time limit in milliseconds to be allowed by the server for processing operations on the cursor.

返り値

This cursor.

エラー / 例外

Throws MongoCursorException if this cursor has started iterating.

Causes methods that fetch results to throw a MongoExecutionTimeoutException if the query takes longer than the specified number of milliseconds in processing time.

例1 MongoCursor::maxTimeMS() example

In the following example, the server will abort the query if the cursor requires more than two seconds in processing time to return its results.

<?php

$cursor 
$collection->find();
$cursor->maxTimeMS(2000);

try {
    
$results iterator_to_array($cursor);
} catch (
MongoExecutionTimeoutException $e) {
    echo 
"query took too long!";
}

?>

注意

警告

Unlike MongoCursor::timeout(), which specifies a client-side timeout, MongoCursor::maxTimeMS() can be used to cause the MongoDB server to abort long-running queries. This timeout is cumulative for the lifetime of the cursor (i.e. each batch will contribute to this time limit). The timeout only considers processing time; idle time is not considered.


忘却曲線を使ってこの知識を確実に記憶に残す

フォーラムで「MongoCursor::maxTimeMS - Sets a server-side timeout for this query」について話す
各種マニュアル: PHPマニュアル | PEARマニュアル | Smarty(英語)マニュアル | PHP-GTKマニュアル | MongoCursor::maxTimeMS - Sets a server-side timeout for this query」をGoogle検索
copyright © 1997-2024 PHP ドキュメント作成グループ(ライセンス). provided by php spot. マニュアル: