現在のユーザーがフォローしているユーザーからのイベントの動的フィードがあり、パーシャルはすべてmemcachedですが、フィード自体に対しても実行したいと思います。私の懸念は、これをmemcacheすると、一意のユーザーごとに動的ではなく、キャッシュへの最初の書き込みに基づいてすべてのユーザーに同じものが表示されることです。
フィードと@followingをmemcacheするにはどうすればよいですか?現在のユーザーが別のユーザーをフォローしている場合、どうすれば更新できますか?<%cache "feed" do%>でラップすることはできないと思います
注:MemcachedとDalliを使用する
<% @following = current_user.following.collect {|f| f["id"]} %>
<div class='content'>
<% unless Rsvp.where(:voter_id => @following, :status => 'going').where("start_time > ? AND start_time < ?", Time.now, Time.now.strftime('%Y-%m-%d 23:59:59.000000')).order("count_all desc").count(:group => :event_id).collect { |f| f[0] }.count == 0 %>
<div class='date_bar_container'><div class='date_bar'>Today</div></div>
<div class='content_wrapper'>
<%= render :partial => 'events/event', :collection => Event.where(:id => Rsvp.where(:event_id => Rsvp.where(:voter_id => @following, :status => 'going').where("start_time > ? AND start_time < ?", Time.now.strftime('%Y-%m-%d 00:00:00.000000'), Time.now.strftime('%Y-%m-%d 23:59:59.000000')).order("count_all desc").count(:group => :event_id).collect { |f| f[0] }).select("DISTINCT event_id").collect(&:event_id)).order('start_time asc')%>
</div>
<% end %>
<% unless Rsvp.where(:voter_id => @following, :status => 'going').where("start_time > ? AND start_time < ?", (Time.now + 1.day).strftime('%Y-%m-%d 00:00:00.000000'), (Time.now + 1.day).strftime('%Y-%m-%d 23:59:59.000000')).order("count_all desc").count(:group => :event_id).collect { |f| f[0] }.count == 0%>
<div class='date_bar_container'><div class='date_bar'>Tomorrow</div></div>
<div class='content_wrapper'>
<%= render :partial => 'events/event', :collection => Event.where(:id => Rsvp.where(:event_id => Rsvp.where(:voter_id => @following, :status => 'going').where("start_time > ? AND start_time < ?", (Time.now + 1.day).strftime('%Y-%m-%d 00:00:00.000000'), (Time.now + 1.day).strftime('%Y-%m-%d 23:59:59.000000')).order("count_all desc").count(:group => :event_id).collect { |f| f[0] }).select("DISTINCT event_id").collect(&:event_id)).order('start_time asc')%>
</div>
<% end %>
<% (2..15).each do |f| %>
<% unless Rsvp.where(:voter_id => @following, :status => 'going').where("start_time > ? AND start_time < ?", (Time.now + f.day).strftime('%Y-%m-%d 00:00:00.000000'), (Time.now + f.day).strftime('%Y-%m-%d 23:59:59.000000')).order("count_all desc").count(:group => :event_id).collect { |f| f[0] }.count == 0 %>
<div class='date_bar_container'><div class='date_bar'><%= dayofweek((Time.now + f.day).wday) %>, <%= month((Time.now + f.day).month) %> <%= (Time.now + f.day).day %>, 2012</div></div>
<div class='content_wrapper'>
<%= render :partial => 'events/event', :collection => Event.where(:id => Rsvp.where(:event_id => Rsvp.where(:voter_id => @following, :status => 'going').where("start_time > ? AND start_time < ?", (Time.now + f.day).strftime('%Y-%m-%d 00:00:00.000000'), (Time.now + f.day).strftime('%Y-%m-%d 23:59:59.000000')).order("count_all desc").count(:group => :event_id).collect { |f| f[0] }).select("DISTINCT event_id").collect(&:event_id)).order('start_time asc')%>
</div>
<% end %>
<% end %>
</div>