mirror of
https://github.com/idanoo/php-resque.git
synced 2024-11-22 08:15:14 +00:00
commit
1d24d009f2
@ -260,11 +260,12 @@ class Resque
|
|||||||
|
|
||||||
// move each item from original queue to temp queue and process it
|
// move each item from original queue to temp queue and process it
|
||||||
$finished = false;
|
$finished = false;
|
||||||
while(!$finished) {
|
while (!$finished) {
|
||||||
$string = self::redis()->rpoplpush($originalQueue, self::redis()->getPrefix() . $tempQueue);
|
$string = self::redis()->rpoplpush($originalQueue, self::redis()->getPrefix() . $tempQueue);
|
||||||
|
|
||||||
if(!empty($string)) {
|
if (!empty($string)) {
|
||||||
if(self::matchItem($string, $items)) {
|
if(self::matchItem($string, $items)) {
|
||||||
|
self::redis()->rpop($tempQueue);
|
||||||
$counter++;
|
$counter++;
|
||||||
} else {
|
} else {
|
||||||
self::redis()->rpoplpush($tempQueue, self::redis()->getPrefix() . $requeueQueue);
|
self::redis()->rpoplpush($tempQueue, self::redis()->getPrefix() . $requeueQueue);
|
||||||
@ -276,7 +277,7 @@ class Resque
|
|||||||
|
|
||||||
// move back from temp queue to original queue
|
// move back from temp queue to original queue
|
||||||
$finished = false;
|
$finished = false;
|
||||||
while(!$finished) {
|
while (!$finished) {
|
||||||
$string = self::redis()->rpoplpush($requeueQueue, self::redis()->getPrefix() .$originalQueue);
|
$string = self::redis()->rpoplpush($requeueQueue, self::redis()->getPrefix() .$originalQueue);
|
||||||
if (empty($string)) {
|
if (empty($string)) {
|
||||||
$finished = true;
|
$finished = true;
|
||||||
|
@ -299,6 +299,29 @@ class Resque_Tests_JobTest extends Resque_Tests_TestCase
|
|||||||
#$this->assertEquals(Resque::size($queue), 1);
|
#$this->assertEquals(Resque::size($queue), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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!');
|
||||||
|
}
|
||||||
|
|
||||||
public function testDequeueItemWithUnorderedArg()
|
public function testDequeueItemWithUnorderedArg()
|
||||||
{
|
{
|
||||||
$queue = 'jobs';
|
$queue = 'jobs';
|
||||||
|
Loading…
Reference in New Issue
Block a user