Ejemplo n.º 1
0
 /**
  * Add task to queue
  *
  * @param \Qutee\Task $task
  *
  * @return \Qutee\Persistor\Redis
  */
 public function addTask(\Qutee\Task $task)
 {
     $queue = $this->_createQueueName($task->getPriority());
     // Remember all the queues we are using
     $this->_getRedis()->sadd('queues', $queue);
     $key = $this->_createKey($task);
     // Check if the task is unique and already exists
     if ($task->isUnique() && $this->_getRedis()->get($key) !== false) {
         return $this;
     }
     // Remember that we set the task to the queue
     $this->_getRedis()->set($key, $queue);
     // Add task to queue
     $data = serialize(array('task' => serialize($task), 'key' => $key));
     $this->_getRedis()->rpush($queue, $data);
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * @covers \Qutee\Task::__construct
  * @depends testCanSetAndGetName
  * @depends testCanSetAndGetData
  */
 public function testCanSettAttributesUpponInstantiation()
 {
     $data = array('test' => 'data');
     $task = new Task('TaskName', $data, Task::PRIORITY_HIGH, 'unique_identifier', 'methodName');
     $this->assertEquals('TaskName', $task->getName());
     $this->assertEquals($data, $task->getData());
     $this->assertEquals('methodName', $task->getMethodName());
     $this->assertEquals(3, $task->getPriority());
     $this->assertEquals(md5('TaskNameunique_identifier'), $task->getUniqueId());
 }