我的 PHP 脚本中的 find() 查询仍然忽略了尝试 mongodb 全局超时等。我想要一个 findOne({...}) 或 find({...}) 查找并在超时前等待数据库服务器最多 20 毫秒。
如何确保 PHP 不将此设置用作软限制?它仍然被忽略并在 5 秒后处理答案。
这是一个 PHP mongo 驱动程序错误吗?
例子:
MongoCursor::$timeout=20;
$nosql_server=new Mongo('mongodb://user:pw@'.implode(",",$arr_replicas).'',array("replicaSet" => "gmt","timeout"=>10)) OR troubles("too slow to connect");
$nosql_db=$nosql_server->selectDB('aDB');
$nosql_collection_mcol=$nosql_db->mcol;
$testFind=$nosql_collection_mcol->find(array('crit'=>123));
//If PHP considered the MongoCursor::$timeout, I'd expect the prev. line to be skipped or throwing a mongo/timeout exception if DB does not return the find result cursor ready within 20ms.
//However, I arrive with this line after seconds, without exception whenever the DB has some lock or delay, without skipping previous line.