public function testExpireJobsWhenExpireSet()
 {
     $this->queue->setExpire(30);
     // Push an item into queue
     $job = new RedisQueueIntegrationTestJob(10);
     $this->queue->push($job);
     // Pop and check it is popped correctly
     $before = time();
     $this->assertEquals($job, unserialize(json_decode($this->queue->pop()->getRawBody())->data->command));
     $after = time();
     // Check reserved queue
     $this->assertEquals(1, $this->redis->connection()->zcard('queues:default:reserved'));
     $result = $this->redis->connection()->zrangebyscore('queues:default:reserved', -INF, INF, ['WITHSCORES' => true]);
     $reservedJob = array_keys($result)[0];
     $score = $result[$reservedJob];
     $this->assertGreaterThanOrEqual($score, $before + 30);
     $this->assertLessThanOrEqual($score, $after + 30);
     $this->assertEquals($job, unserialize(json_decode($reservedJob)->data->command));
 }
Esempio n. 2
0
 /**
  * Establish a queue connection.
  *
  * @param  array  $config
  * @return \Illuminate\Contracts\Queue\Queue
  */
 public function connect(array $config)
 {
     $queue = new RedisQueue($this->redis, $config['queue'], Arr::get($config, 'connection', $this->connection));
     $queue->setExpire(Arr::get($config, 'expire', 60));
     return $queue;
 }