app/services/news_feed.rb
# Fetch a page of stories from the user's timeline. Generate a timeline if
# the user's timeline doesn't already exist in memory.
Fetch a page of stories from the user's timeline. Generate a timeline if
the user's timeline doesn't already exist in memory.
Fetch a page of stories from the user ' s timeline . Generate a timeline if the user ' s timeline doesn ' t already exist in memory .
def fetch(page=nil)
    regenerate_feed! unless cached?
    page ||= 1
    start_index = 30 * (page.to_i-1)
    stop_index = start_index + 30 - 1
    story_ids = []
    $redis.with do |conn|
      conn.expire @feed_key, INACTIVE_DAYS * 24 * 60 * 60
      story_ids = conn.zrevrange(@feed_key, start_index, stop_index).collect(&:to_i)
    end
    StoryQuery.find_by_ids(story_ids, @user)
  end
def fetch ( page = nil ) regenerate_feed! unless cached? page ||= 1 start_index = 30 * ( page . to_i - 1 ) stop_index = start_index + 30 - 1 story_ids = [ ] $redis . with do | conn | conn . expire @feed_key , INACTIVE_DAYS * 24 * 60 * 60 story_ids = conn . zrevrange ( @feed_key , start_index , stop_index ) . collect ( & :to_i ) end StoryQuery . find_by_ids ( story_ids , @user ) end
Fetch a page of stories from the user's timeline.
Fetch a page of stories from the user ' s timeline .
page
<not_specific>