comparison app/models/tweet.rb @ 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 924b3a4ed3ef
children cf9a9ce2d034
comparison
equal deleted inserted replaced
85:101904debfcd 86:5bfc986200db
1 class Tweet 1 class Tweet
2 def timeline(options = {}) 2 def timeline
3 start_client_config_id = @client_config_id 3 start_client_config_id = @client_config_id
4 4
5 begin 5 begin
6 @timeline ||= 6 @timeline ||=
7 Rails.cache.fetch({ :timeline => @twitter_id, :options => options.dup }, :expires_in => 5.minutes) do 7 Rails.cache.fetch({ :timeline => @twitter_id }, :expires_in => 5.minutes) do
8 @client.user_timeline(@twitter_id, options) 8 @client.user_timeline(@twitter_id, :count => 40, :exclude_replies => false, :include_rts => true)
9 end 9 end
10 rescue Twitter::Error::TooManyRequests 10 rescue Twitter::Error::TooManyRequests
11 next_client_config_id = @client_config_id + 1 11 next_client_config_id = @client_config_id + 1
12 init_client next_client_config_id 12 init_client next_client_config_id
13 13