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
}