/** * Retrieves the track with the given identity. * * @param TrackIdentity $identity The identity of the track to retrieve. * @return Domain\Entity\Track * @throws Domain\Exception\TrackNotFoundException If no track has the requested identity. */ public function get(TrackIdentity $identity) { try { $raw_track = $this->spotify_api->getTrack($identity->getId()); return $this->buildTrack($raw_track); } catch (NotFoundException $e) { throw new TrackNotFoundException(); } }
public function get(TrackIdentity $identity) { $key = self::PRE_KEY . $identity->getId(); $track = $this->redis->get($key); if (!$track) { $track = $this->repository->get($identity); $this->redis->set($key, $track); } return $track; }