title: Can I cache a result using the Twitter gem? (Rails 4)
body: <p>I'm using the <a href="https://github.com/sferik/twitter" rel="nofollow">Twitter Gem</a>. </p>
  
  <p>My Model:</p>
  
  <pre><code>class TweetyClass
    def initialize
      @client = Twitter::REST::Client.new do |config|
        config.consumer_key        = TWITTER_CONFIG['consumer_key']
        config.consumer_secret     = TWITTER_CONFIG['consumer_secret']
        config.access_token        = TWITTER_CONFIG['access_token']
        config.access_token_secret = TWITTER_CONFIG['access_token_secret']
      end
    end
  
    def user_timeline
      @client.user_timeline( count: 2)
    end
  end
  </code></pre>
  
  <p>My Controller:</p>
  
  <pre><code>def tweets
    @tweets = TweetyClass.new.user_timeline
  end
  </code></pre>
  
  <p>My View: </p>
  
  <pre><code>&lt;% @tweets.each do |tweet| %&gt;
  
    &lt;li&gt;&lt;%= tweet.foo%&gt;&lt;/li&gt;
  
  &lt;% end %&gt;
  </code></pre>
  
  <p>Is there a way to cache the results so each time I call <strong>user_timeline</strong> it fetches the result from the app/app variable rather than going to Twitter and fetching the timeline of Tweets. </p>
  
  <p>Apologies if I'm not using the correct terminology; I'm new to the subject of caching. Essentially what I want to do is improve the speed of my app and one thing that seems to slow it down is the time it takes to retrieve tweets using the user_timeline method. I'm assuming it's because it's retrieving this from Twitter each time and I thought caching may assist. </p>