0
私はSSEで私のレールアプリをストリーミングしようとしています。キャッシングが私のライブストリームを台無しにしています
このコードは動作しますが、私のブラウザにはストリーミングされていますが、count
はチャットされているようです。コンソールで変更すると、このコントローラに同じ内容が保持されるためです。
class SseController < ActionController::Base
include ActionController::Live
def stream
response.headers['Content-Type'] = 'text/event-stream'
sse = SSE.new(response.stream)
begin
loop do
count = Email.where(:read => false, :folder_id => nil, :deleted => false, :outgoing => false, :spam => false).count
sse.write(count, :event => 'refresh')
sleep 10
end
rescue
ensure
sse.close
end
end
end
私はコンソールでこの部分を行うとき。それは期待どおりに動作します。
loop do
count = Email.where(:read => false, :folder_id => nil, :deleted => false, :outgoing => false, :spam => false).count
sse.write(count, :event => 'refresh')
sleep 10
end
私のSseController(:: Live)でチャーチを読み書きしたり、正しい数を読み取ったりするにはどうすればよいですか?