How to use Phalcon\Queue\Beanstalk?

http://docs.phalconphp.com/en/latest/reference/queue.html

<?php

//Connect to the queue
$queue = new Phalcon\Queue\Beanstalk(array(
    'host' => '192.168.0.21'
));

//Insert the job in the queue
$queue->put(array('processVideo' => 4871));

processVideo is name of job? What mean 4871? Where processVideo should be defined?



33.9k

processVideo is just a key to store it in your queue. You can name it whatever you want. 4871 is the id of the video. A simple example would be if you have a table in database that holds information about video files that needs to be processed:

Table columns id, filepath, isprocessed

When you upload a video file, you store the information in your video table, with flag is_processed = 0 , then you add the file to the queue

$video = new VideoModel();
$video->setFilePath('PATH_TO_VIDEO_FILE');
$video->setIsProcessed(0);
$video->save();

// $video->getId() will give you the id (in the above example 4871)
$queue->put(array('processVideo' => $video->getId()));