Class: Timeline
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Timeline
- Defined in:
- app/models/timeline.rb
Constant Summary collapse
- TIMEOUT =
10- TTL =
30.minutes
Instance Method Summary collapse
Instance Method Details
#get_timeline(tweet_name, tweet_amount = 1) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'app/models/timeline.rb', line 7 def get_timeline(tweet_name, tweet_amount=1) # Remove the cached timeline if its expired if self.expires_at.nil? || self.expires_at < Time.now.utc Rails.cache.delete('Timeline.Tweets_'+ tweet_name + "_" + tweet_amount.to_s) end # Make sure to invalidate the cache if the amount chanages Rails.cache.fetch('Timeline.Tweets_'+ tweet_name + "_" + tweet_amount.to_s) { get_timeline_from_twitter(tweet_amount) } end |