public function init()
{
$job = $this->job = new \PHPDaemon\Core\ComplexJob(function ($job) {
// called when job is done
// prevent cleaning up results
$job->keep();
// wake up the request immediately
$this->wakeup();
});
// just pushing something
$this->appInstance->redis->lpush('mylist', microtime(true));
// registering job named 'testquery'
$job('testquery', function ($name, $job) {
$this->appInstance->redis->lrange('mylist', 0, 10, function ($conn) use($name, $job) {
// calling lrange Redis command
// setting job result
$job->setResult($name, $conn->result);
});
});
// let the fun begin
$job();
// setting timeout
$this->sleep(1, true);
}