/**
  * @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);
 }
 /**
  * {@inheritDoc}
  */
 public function save(WorkerInterface $worker)
 {
     $currentJob = $worker->getCurrentJob();
     $this->redis->sadd('workers', $worker->getId());
     $this->redis->set('worker:' . $worker->getId() . ':started', date('c'));
     // @todo worker->getStartedAt()
     if ($currentJob) {
         $payload = json_encode(array('queue' => $currentJob instanceof OriginQueueAwareInterface ? $currentJob->getOriginQueue() : null, 'run_at' => date('c'), 'payload' => $currentJob->encode()));
         $this->redis->set('worker:' . $worker->getId(), $payload);
     } else {
         $this->redis->del('worker:' . $worker->getId());
     }
     // @todo use multi -> exec or something.
 }