コード例 #1
0
ファイル: TrackRepository.php プロジェクト: alexgt9/PlayCool
 /**
  * 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();
     }
 }
コード例 #2
0
ファイル: TrackRepository.php プロジェクト: alexgt9/PlayCool
 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;
 }