Mercurial > rsstweet
comparison app/models/tweet.rb @ 88:cf9a9ce2d034
Increase cache timeout to ease up load ;_;
author | nanaya <me@myconan.net> |
---|---|
date | Tue, 28 Jun 2016 02:38:27 +0900 |
parents | 5bfc986200db |
children | ff5557f9902c |
comparison
equal
deleted
inserted
replaced
87:b01b5265e6d1 | 88:cf9a9ce2d034 |
---|---|
2 def timeline | 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 }, :expires_in => 5.minutes) do | 7 Rails.cache.fetch({ :timeline => @twitter_id }, :expires_in => 20.minutes) do |
8 @client.user_timeline(@twitter_id, :count => 40, :exclude_replies => false, :include_rts => true) | 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 |
22 def user | 22 def user |
23 @user ||= | 23 @user ||= |
24 if timeline.any? | 24 if timeline.any? |
25 timeline.first.user | 25 timeline.first.user |
26 else | 26 else |
27 Rails.cache.fetch({ :user => @twitter_id }, :expires_in => 5.minutes) do | 27 Rails.cache.fetch({ :user => @twitter_id }, :expires_in => 20.minutes) do |
28 @client.user(@twitter_id) | 28 @client.user(@twitter_id) |
29 end | 29 end |
30 end | 30 end |
31 end | 31 end |
32 | 32 |