/**
  * {@inheritDoc}
  */
 public function track(TrackableJobInterface $job)
 {
     $statusPacket = array('status' => $job->getState(), 'updated' => date('c'));
     $this->redis->set($this->getRedisKey($job), json_encode($statusPacket));
     // Expire the status for completed jobs after 24 hours
     if (in_array($job->getState(), static::$completedStates)) {
         $this->redis->expire($this->getRedisKey($job), 86400);
     }
 }
 /**
  * @todo need to sort out encoding. This only hard because of the date('c') calls with RedisWorkerRegistryAdapter.
  */
 function it_correctly_saves_a_workers_current_job_to_redis(RedisClientInterface $redis, WorkerInterface $worker, JobInterface $job)
 {
     $worker->getId()->shouldBeCalled()->willReturn('foo:333');
     $worker->getCurrentJob()->shouldBeCalled()->willReturn($job);
     $job->encode()->shouldBeCalled()->willReturn('encoded-job');
     $redis->sadd('workers', 'foo:333')->shouldBeCalled();
     $redis->set('worker:foo:333:started', Argument::any())->shouldBeCalled();
     $redis->set('worker:foo:333', Argument::any())->shouldBeCalled();
     $this->save($worker);
 }
 function it_on_tracking_a_completion_status_sets_key_to_expire(RedisClientInterface $redis, TrackableJobInterface $job)
 {
     $job->getState()->shouldBeCalled()->willReturn(JobInterface::STATE_COMPLETE);
     $job->getId()->shouldBeCalled()->willReturn('id');
     $redis->set('job:id:status', Argument::type('string'))->shouldBeCalled();
     $redis->expire('job:id:status', 86400)->shouldBeCalled();
     $this->track($job)->shouldReturn(null);
 }