/** * Add the task to the queue * * @param string $queue The queue to use * @param Lilmuckers_Queue_Model_Queue_Task $task The task to assign * * @return Lilmuckers_Queue_Model_Adapter_Beanstalk */ protected function _addToQueue($queue, Lilmuckers_Queue_Model_Queue_Task $task) { //load the default prioriy, delay and ttr data $_priority = is_null($task->getPriority()) ? $this->_priority : $task->getPriority(); $_delay = is_null($task->getDelay()) ? $this->_delay : $task->getDelay(); $_ttr = is_null($task->getTtr()) ? $this->_ttr : $task->getTtr(); //load the json string for the task $_data = $task->exportData(); //send this data to the beanstalkd server $this->getConnection()->useTube($queue)->put($_data, $_priority, $_delay, $_ttr); return $this; }
/** * Add the task to the queue * * @param string $queue The queue to use * @param Lilmuckers_Queue_Model_Queue_Task $task The task to assign * * @return Lilmuckers_Queue_Model_Adapter_Gearman */ protected function _addToQueue($queue, Lilmuckers_Queue_Model_Queue_Task $task) { //load the default prioriy, delay and ttr data $_priority = is_null($task->getPriority()) ? null : $task->getPriority(); //load the json string for the task $_data = $task->exportData(); //split the priority into ranges $_priorityIncrement = self::PRIORITY_MAX / 3; //Send the task to the right priority level if (0 <= $_priority && $_priorityIncrement > $_priority) { //high priority //send this data to the gearman server $this->getClientConnection()->doHighBackground($queue, $_data); } elseif ($_priorityIncrement <= $_priority && $_priorityIncrement * 2 > $_priority) { //medium priority //send this data to the gearman server $this->getClientConnection()->doBackground($queue, $_data); } elseif ($_priorityIncrement * 2 <= $_priority && self::PRIORITY_MAX >= $_priority) { //low priority //send this data to the gearman server $this->getClientConnection()->doLowBackground($queue, $_data); } return $this; }