本文整理汇总了PHP中MongoClient::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoClient::getInstance方法的具体用法?PHP MongoClient::getInstance怎么用?PHP MongoClient::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoClient
的用法示例。
在下文中一共展示了MongoClient::getInstance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Constructor.
* @return void
*/
public function init()
{
$this->timeStart = microtime(true);
$this->db = \MongoClient::getInstance();
$this->mongo = \PHPDaemon\Clients\Mongo\Pool::getInstance(['maxconnperserv' => 100]);
$this->collection = $this->mongo->{'MongoAsync.MongoAsync'};
}
示例2: init
/**
* Constructor.
* @return void
*/
public function init()
{
if ($this->isEnabled()) {
$this->client = \PHPDaemon\Clients\Valve\Pool::getInstance();
$this->db = \MongoClient::getInstance();
$this->servers = $this->db->{$this->config->dbname->value . '.servers'};
}
}
示例3: init
/**
* Constructor.
* @return void
*/
public function init()
{
$req = $this;
$job = $this->job = new ComplexJob(function () use($req) {
// called when job is done
$req->wakeup();
// wake up the request immediately
});
$mongo = MongoClient::getInstance();
$collection = $mongo->{'testdb.testcollection'};
$collection->insert(array('a' => microtime(true)));
// just pushing something
$job('testquery', function ($name, $job) use($collection) {
// registering job named 'testquery'
$collection->findOne(function ($result) use($name, $job) {
// calling Mongo findOne
$job->setResult($name, $result);
}, array('sort' => array('$natural' => -1)));
});
$job();
// let the fun begin
$this->sleep(1, true);
// setting timeout
}