예제 #1
0
 /**
  * Internal method to get the latest photos
  * @param int $limit Limit
  * @return array
  * @uses MeInstagram\Utility\Instagram::recent()
  */
 protected function _latest($limit = 15)
 {
     //Tries to get data from the cache
     $photos = Cache::read($cache = sprintf('latest_%s', $limit), 'instagram');
     //If the data are not available from the cache
     if (empty($photos)) {
         list($photos) = Instagram::recent(null, $limit);
         Cache::write($cache, $photos, 'instagram');
     }
     return $photos;
 }
 /**
  * Lists photos from Istangram
  * @param string $id Request ID ("Next ID" for Istangram)
  * @return void
  * @uses MeInstagram\Utility\Instagram::recent()
  */
 public function index($id = null)
 {
     //Sets initial cache name
     $cache = sprintf('index_limit_%s', config('default.photos'));
     //Adds the request ID ("Next ID" for Istangram) to the cache name
     if (!empty($id)) {
         $cache = sprintf('%s_id_%s', $cache, $id);
     }
     //Tries to get data from the cache
     list($photos, $nextId) = Cache::read($cache, 'instagram');
     //If the data are not available from the cache
     if (empty($photos)) {
         list($photos, $nextId) = Instagram::recent($id, config('default.photos'));
         Cache::write($cache, [$photos, $nextId], 'instagram');
     }
     $this->set(compact('photos', 'nextId'));
 }