示例#1
0
文件: Pdo.php 项目: anorgan/qutee
 /**
  * 
  * @param \Qutee\Task $task
  *
  * @return \Qutee\Persistor\Pdo
  */
 public function addTask(Task $task)
 {
     // Check if the task is unique and already exists
     if ($task->isUnique() && $this->_hasTaskByUniqueId($task->getUniqueId())) {
         return $this;
     }
     $statement = $this->_getPdo()->prepare(sprintf(' 
         INSERT INTO %s
         SET
             name        = :name,
             method_name = :method_name,
             data        = :data,
             priority    = :priority,
             unique_id   = :unique_id,
             created_at  = NOW()
     ', $this->_options['table_name']));
     $statement->execute(array(':name' => $task->getName(), ':method_name' => $task->getMethodName(), ':data' => serialize($task), ':priority' => $task->getPriority(), ':unique_id' => $task->isUnique() ? $task->getUniqueId() : null));
     return $this;
 }
示例#2
0
文件: Redis.php 项目: anorgan/qutee
 /**
  *
  * @param \Qutee\Task $task
  *
  * @return string
  */
 protected function _createKey(\Qutee\Task $task)
 {
     if ($task->isUnique()) {
         $key = sprintf('task:%s:%s', $task->getName(), $task->getUniqueId());
     } else {
         $key = sprintf('task:%s:%s', $task->getName(), uniqid('', true));
     }
     return $key;
 }
示例#3
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());
 }