Author: Vasily Zorin (maintainer@daemon.io)
Inheritance: extends PHPDaemon\Network\Client
 /**
  * Constructor.
  * @return void
  */
 public function init()
 {
     try {
         $this->header('Content-Type: text/html');
     } catch (\Exception $e) {
     }
     $req = $this;
     $job = $this->job = new \PHPDaemon\Core\ComplexJob(function () use($req) {
         // called when job is done
         $req->wakeup();
         // wake up the request immediately
     });
     $memcache = \PHPDaemon\Clients\Memcache\Pool::getInstance();
     $job('testquery', function ($name, $job) use($memcache) {
         // registering job named 'testquery'
         $memcache->stats(function ($memcache) use($name, $job) {
             // calling 'stats'
             $job->setResult($name, $memcache->result);
             // setting job result
         });
     });
     $job();
     // let the fun begin
     $this->sleep(5, true);
     // setting timeout
 }
Example #2
0
 /**
  * Constructor.
  * @return void
  */
 public function init()
 {
     $this->db = \PHPDaemon\Clients\Mongo\Pool::getInstance($this->config->mongoclientname->value);
     $this->cache = \PHPDaemon\Clients\Memcache\Pool::getInstance($this->config->memcacheclientname->value);
     if (!isset($this->config->limitinstances)) {
         $this->log('missing \'limitInstances\' directive');
     }
 }
Example #3
0
 /**
  * @param Request $req
  */
 public function __construct($req)
 {
     $this->req = $req;
     $this->appInstance = $req->appInstance;
     $this->dbname =& $this->appInstance->dbname;
     Daemon::log(__CLASS__ . ' up.');
     $this->db = $this->appInstance->db;
     $this->ORM = new MUChat($this);
     $this->tags = array();
     $this->minMsgInterval = 1;
     $this->cache = \PHPDaemon\Clients\Memcache\Pool::getInstance();
     $this->ipcId = sprintf('%x', crc32(Daemon::$process->pid . '-' . microtime(true)));
     $my_class = ClassFinder::getClassBasename($this);
     $this->config = isset($this->appInstance->config->{$my_class}) ? $this->appInstance->config->{$my_class} : null;
     $defaults = $this->getConfigDefaults();
     if ($defaults) {
         $this->processDefaultConfig($defaults);
     }
     $this->dbname = $this->config->dbname->value;
     $this->init();
     $this->onReady();
 }