Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетил 16131 программист и 1779 роботов. Сейчас ищут 1417 программистов ...
Приступая к работе

MongoCursor::maxTimeMS - Sets a server-side timeout for this query

Вернуться к: MongoCursor

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

© 2024 «PHP.RU — Сообщество PHP-Программистов»
Главная | Форум | Реклама на сайте | Контакты VIP Сувениры
Разработка компании ODware