Class: Timeline

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/timeline.rb

Constant Summary collapse

TIMEOUT =
10
TTL =
30.minutes

Instance Method Summary collapse

Instance Method Details

#get_timeline(tweet_amount = 1) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/timeline.rb', line 10

def get_timeline(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') 
  end

  # Make sure to invalidate the cache if the amount chanages
  Rails.cache.fetch('Timeline.Tweets' + tweet_amount.to_s) { get_timeline_from_twitter(tweet_amount) }
  
end