/**
  * Retrieves (up to) the last $count tweets from $user.
  *
  * Note: Actual returned number may be less than 10 due to reasons
  *
  * @param string $user Username to search for
  * @param integer $count Number of tweets
  * @return ArrayList List of tweets
  */
 public function LatestTweetsUser($user, $count = 10)
 {
     // Check that the twitter user is configured
     if (empty($user)) {
         return null;
     }
     $tweets = $this->twitterService->getTweets($user, $count);
     return $this->viewableTweets($tweets);
 }
 public function getTweets($user, $count)
 {
     // Init caching
     $cacheKey = "getTweets_{$user}_{$count}";
     $cache = SS_Cache::factory('CachedTwitterService');
     // Return cached value, if available
     if ($rawResult = $cache->load($cacheKey)) {
         return unserialize($rawResult);
     }
     // Save and return
     $result = $this->cachedService->getTweets($user, $count);
     $cache->save(serialize($result), $cacheKey, array(), Config::inst()->get('CachedTwitterService', 'lifetime'));
     // Refresh the 'TimeAgo' field, as the cached value would now be outdated, or the locale could have changed.
     if ($result) {
         foreach ($result as $index => $item) {
             $result[$index]['TimeAgo'] = TwitterService::determine_time_ago($item['Date']);
         }
     }
     return $result;
 }