Пример #1
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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
 }