diff app/models/tweet.rb @ 28:03f904c070f7

Basic caching support.
author edogawaconan <me@myconan.net>
date Sat, 06 Sep 2014 00:46:25 +0900
parents b82d86b74636
children 205c0b5d9f44
line wrap: on
line diff
--- a/app/models/tweet.rb	Sat Sep 06 00:08:18 2014 +0900
+++ b/app/models/tweet.rb	Sat Sep 06 00:46:25 2014 +0900
@@ -7,7 +7,10 @@
   }
 
   def timeline
-    @timeline ||= @client.user_timeline(@twitter_id)
+    @timeline ||=
+      Rails.cache.fetch :timeline => @twitter_id, :expires_in => 5.minutes do
+        @client.user_timeline(@twitter_id)
+      end
   end
 
   def initialize(twitter_id)