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); }
/** * {@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); } }