それはstackoverflowの私の最初の質問です。
私のアプリケーションでは、Webの動きを確認するためのリアルタイムセクションがあります。そのオンライン新聞とこのセクションは、新しい記事、新しいコメント、新しい投票、新しい討論.....ウェブ上で起こっていることすべてを示しています。
私はこのコードを持っています:
def index
@objects = Article.find(:all, :conditions => { :created_at => (Time.now-48.hours)..(Time.now), :published => true })
@objects = @objects + Debate.find(:all, :conditions => { :created_at => (Time.now-48.hours)..(Time.now), :active => true })
@objects = @objects + Event.find(:all, :conditions => { :created_at => (Time.now-48.hours)..(Time.now), :active => true })
@objects = @objects + Comment.find(:all, :conditions => { :created_at => (Time.now-48.hours)..(Time.now), :active => true })
@objects = @objects + Vote.find(:all, :conditions => { :created_at => (Time.now-48.hours)..(Time.now) })
@objects.sort! {|x,z| x.created_at <=> z.created_at}
@objects.reverse!
end
過去48時間ですべてをロードします。これは私の解決策ではないと思うので、私はRailsでのキャッシュについて読んでいます。
このリストをより速くロードするにはどうすればよいですか?今は7...または8秒かかるので...
すべてに感謝します:D