function it_deletes_queue_from_redis(QueueInterface $queue, RedisClientInterface $redis)
 {
     $queue->getName()->shouldBeCalled()->willReturn('high');
     $redis->multi()->shouldBeCalled();
     $redis->llen('queue:high')->shouldBeCalled();
     $redis->del('queue:high')->shouldBeCalled();
     $redis->srem('queues', 'high')->shouldBeCalled();
     $redis->exec()->shouldBeCalled()->willReturn(array(5));
     $this->delete($queue)->shouldReturn(5);
 }
 /**
  * {@inheritDoc}
  */
 public function delete(QueueInterface $queue)
 {
     if (!isset($this->queues[$queue->getName()])) {
         return 0;
     }
     $queue = $this->queues[$queue->getName()];
     $jobCount = $queue->count();
     unset($this->queues[$queue->getName()]);
     return $jobCount;
 }
Exemplo n.º 3
0
 function it_dequeues_jobs_from_only_matching_queues(QueueRegistryInterface $registry, QueueInterface $queueBaz, QueueInterface $queueFoo, JobInterface $jobFoo)
 {
     $this->beConstructedWith($registry, 'foo');
     $this->getPrefix()->shouldReturn('foo');
     $registry->all()->willReturn([$queueBaz, $queueFoo]);
     $queueBaz->getName()->willReturn('baz');
     $queueFoo->getName()->willReturn('foo');
     $queueBaz->dequeue()->shouldNotBeCalled();
     $queueFoo->dequeue()->shouldBeCalled(1)->willReturn($jobFoo);
     $this->dequeue()->shouldReturn($jobFoo);
 }
 protected function processQueueJobs(QueueInterface $queue)
 {
     while ($job = $queue->dequeue()) {
         $this->executeJob($job);
     }
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function addQueue(QueueInterface $queue)
 {
     $this->queues[$queue->getName()] = $queue;
     return $this;
 }
Exemplo n.º 6
0
 /**
  * Get redis key.
  *
  * @param QueueInterface $queue A the queue to the get the Resque Redis key name for.
  * @return string Key name for Redis.
  */
 protected function getRedisKey(QueueInterface $queue)
 {
     return 'queue:' . $queue->getName();
 }
Exemplo n.º 7
0
 function it_can_count_pushed_jobs(RedisClientInterface $redis, QueueInterface $queue)
 {
     $queue->getName()->shouldBeCalled()->willReturn('foo');
     $redis->llen('queue:foo')->shouldBeCalled()->willReturn(2);
     $this->count($queue)->shouldReturn(2);
 }
 /**
  * {@inheritDoc}
  */
 public function save(QueueInterface $queue)
 {
     $this->redis->sadd('queues', $queue->getName());
     return $this;
 }