# HG changeset patch # User nanaya # Date 1466972050 -32400 # Node ID 5bfc986200db83f3068e28fbcf87584b3ef8f005 # Parent 101904debfcdbed74de6639d5661dac0c606b1e5 The caching becomes a bit confusing because of parameters diff -r 101904debfcd -r 5bfc986200db app/controllers/tweets_controller.rb --- a/app/controllers/tweets_controller.rb Mon Jun 27 05:12:40 2016 +0900 +++ b/app/controllers/tweets_controller.rb Mon Jun 27 05:14:10 2016 +0900 @@ -6,7 +6,7 @@ def show client = Tweet.new(params[:id]) - @tweets = client.timeline :exclude_replies => false, :count => 40 + @tweets = client.timeline @user = client.user rescue Twitter::Error::NotFound head :not_found diff -r 101904debfcd -r 5bfc986200db app/models/tweet.rb --- a/app/models/tweet.rb Mon Jun 27 05:12:40 2016 +0900 +++ b/app/models/tweet.rb Mon Jun 27 05:14:10 2016 +0900 @@ -1,11 +1,11 @@ class Tweet - def timeline(options = {}) + def timeline start_client_config_id = @client_config_id begin @timeline ||= - Rails.cache.fetch({ :timeline => @twitter_id, :options => options.dup }, :expires_in => 5.minutes) do - @client.user_timeline(@twitter_id, options) + Rails.cache.fetch({ :timeline => @twitter_id }, :expires_in => 5.minutes) do + @client.user_timeline(@twitter_id, :count => 40, :exclude_replies => false, :include_rts => true) end rescue Twitter::Error::TooManyRequests next_client_config_id = @client_config_id + 1