M
M
mitaichik2015-04-28 01:26:44
PHP
mitaichik, 2015-04-28 01:26:44

How to set timeout on MongoDb aggregation in php?

Hello. I do aggregation from php:

$data = self::getCollection()->aggregate(
                [...],
                ['allowDiskUse' => true]
        );

The request is very long, you need to set a timeout (the default of 30 seconds is not suitable).
Question: how to make it? In the manuals, it is written everywhere to set a timeout for the cursor. But the cursor is not used here.
I decided to make a crutch:
\MongoCursor::$timeout = -1;    // Костыль для таймаута
$data = self::getCollection()->aggregate(...);
\MongoCursor::$timeout = 30000; // Возвращаем таймаут обратно

It works, but in the logs I get an error:
MongoCollection::aggregate(): The 'MongoCursor::$timeout' static property is deprecated, please call MongoCursor->timeout() instead E_DEPRECATED

What to do? Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gregory, 2015-04-28
@difiso

Duck do what is suggested in the logs. What is the problem? Are you afraid to translate the message or find out what E_DEPRECATED means?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question