PHPDaemon\Clients\Redis\Examples\SimpleRequest::init PHP Method

init() public method

Constructor.
public init ( ) : void
return void
    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);
    }
SimpleRequest