pop() public static method

Pop an item off the end of the specified queue, decode it and return it.
public static pop ( string $queue ) : array
$queue string The name of the queue to fetch an item from.
return array Decoded item from the queue.
Esempio n. 1
0
 /**
  * Find the next available job from the specified queue and return an
  * instance of Resque_Job for it.
  *
  * @param string $queue The name of the queue to check for a job in.
  * @return null|object Null when there aren't any waiting jobs, instance of Resque_Job when a job was found.
  */
 public static function reserve($queue)
 {
     $payload = Resque::pop($queue);
     if (!is_array($payload)) {
         return false;
     }
     return new Resque_Job($queue, $payload);
 }
Esempio n. 2
0
 /**
  * Find the next available job from the specified queue and return an
  * instance of Resque_Job for it.
  *
  * @param string $queue The name of the queue to check for a job in.
  * @return null|object Null when there aren't any waiting jobs, instance of Resque_Job when a job was found.
  */
 public static function reserve($queue, $sm = null)
 {
     $payload = \Resque::pop($queue);
     if (!is_array($payload)) {
         return false;
     }
     return new ResqueJob($queue, $payload, $sm);
 }
Esempio n. 3
0
	/**
	 * Find the next available job from the specified queue and return an
	 * instance of Resque_Job for it.
	 *
	 * @param string $queue The name of the queue to check for a job in.
	 * @return null|object Null when there aren't any waiting jobs, instance of Resque_Job when a job was found.
	 */
	public static function reserve($queue)
	{
		$payload = Resque::pop($queue);
		if(!$payload) {
			return;
		}

		return new Resque_Job($queue, $payload);
	}
 /**
  * Find the next available job from the specified queue and return an
  * instance of Resque_Job for it.
  *
  * @param string $queue The name of the queue to check for a job in.
  * @return null|object Null when there aren't any waiting jobs, instance of Resque_Job when a job was found.
  */
 public static function reserve($queue)
 {
     // 出队,拿到最早的job数据
     $payload = Resque::pop($queue);
     if (!is_array($payload)) {
         return false;
     }
     // 创建一个新的job
     return new Resque_Job($queue, $payload);
 }
Esempio n. 5
0
 public static function reserve($queue)
 {
     $payload = Resque::pop($queue);
     if (!is_array($payload)) {
         return false;
     }
     if (isset($payload['closure'])) {
         return new Resque_Job_Closure($queue, $payload);
     } else {
         return new Resque_Job_Class($queue, $payload);
     }
 }
Esempio n. 6
0
 public function testDequeueSeveralItemsWithArgs()
 {
     // GIVEN
     $queue = 'jobs';
     $args = array('foo' => 1, 'bar' => 10);
     $removeArgs = array('foo' => 1, 'bar' => 2);
     Resque::enqueue($queue, 'Test_Job_Dequeue9', $args);
     Resque::enqueue($queue, 'Test_Job_Dequeue9', $removeArgs);
     Resque::enqueue($queue, 'Test_Job_Dequeue9', $removeArgs);
     $this->assertEquals(Resque::size($queue), 3);
     // WHEN
     $test = array('Test_Job_Dequeue9' => $removeArgs);
     $removedItems = Resque::dequeue($queue, $test);
     // THEN
     $this->assertEquals($removedItems, 2);
     $this->assertEquals(Resque::size($queue), 1);
     $item = Resque::pop($queue);
     $this->assertInternalType('array', $item['args']);
     $this->assertEquals(10, $item['args'][0]['bar'], 'Wrong items were dequeued from queue!');
 }