public function init()
{
$job = $this->job = new \PHPDaemon\Core\ComplexJob(function ($job) {
// called when job is done
$this->wakeup();
// wake up the request immediately
$job->keep();
// prevent from cleaning
});
if (isset($_GET['fill'])) {
for ($i = 0; $i < 100; ++$i) {
$this->appInstance->gibson->set(3600, 'key' . $i, 'val' . $i);
}
}
$job('testquery', function ($jobname, $job) {
// registering job named 'testquery'
$this->appInstance->gibson->mget('key99', function ($conn) use($job, $jobname) {
if ($conn->isFinal()) {
$job->setResult($jobname, $conn->result);
}
});
});
$job();
// let the fun begin
$this->sleep(1, true);
// setting timeout*/
}