changeset 86:5bfc986200db

The caching becomes a bit confusing because of parameters
author nanaya <me@myconan.net>
date Mon, 27 Jun 2016 05:14:10 +0900
parents 101904debfcd
children b01b5265e6d1
files app/controllers/tweets_controller.rb app/models/tweet.rb
diffstat 2 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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