comparison 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
comparison
equal deleted inserted replaced
27:efc548be0a3a 28:03f904c070f7
5 :access_token => ENV["RT_ACCESS_TOKEN"], 5 :access_token => ENV["RT_ACCESS_TOKEN"],
6 :access_token_secret => ENV["RT_ACCESS_TOKEN_SECRET"] 6 :access_token_secret => ENV["RT_ACCESS_TOKEN_SECRET"]
7 } 7 }
8 8
9 def timeline 9 def timeline
10 @timeline ||= @client.user_timeline(@twitter_id) 10 @timeline ||=
11 Rails.cache.fetch :timeline => @twitter_id, :expires_in => 5.minutes do
12 @client.user_timeline(@twitter_id)
13 end
11 end 14 end
12 15
13 def initialize(twitter_id) 16 def initialize(twitter_id)
14 @client = Twitter::REST::Client.new do |config| 17 @client = Twitter::REST::Client.new do |config|
15 CONFIG.each do |cfg_key, cfg_value| 18 CONFIG.each do |cfg_key, cfg_value|