Thursday, 15 April 2010

PHP MongoDb driver: How to set timeout for executing a code -



PHP MongoDb driver: How to set timeout for executing a code -

i have next code executes piece of code on mongodb's side:

$mongocode = new mongocode('/* js code */'); $db->execute($mongocode, array( 'sockettimeoutms' => 1000000, ));

as see have tried set timeout code's execution setting sockettimeoutms value in sec parameter of execute() function. not work. documentations in php website indicate sec parameter of execute() command sent code arguments. how can set timeout mongodb::execute()? please note using version 1.5 of mongodb driver php , mongocursor::$timeout deprecated , not work anymore.

you can set sockettimeoutms on mongoclient:

$mongo = new mongoclient("mongodb://localhost:27017", array( "sockettimeoutms" => 100000 ) );

the args parameters execute method passed code (your javascript function) not driver.

alternatively, can set timeout on cursor this:

$cursor = $collection->find(array()); $cursor->timeout(10000);

but not work on execute command, because command doesn't homecoming cursor.

php mongodb

No comments:

Post a Comment