Backport: Propagate broadcast messages to secondaries

This commit is contained in:
Michael Kozono 2018-04-11 10:49:56 -07:00
parent 37a5632483
commit 1ce0595b18
2 changed files with 10 additions and 2 deletions

View File

@ -19,7 +19,7 @@ class BroadcastMessage < ActiveRecord::Base
after_commit :flush_redis_cache
def self.current
messages = Rails.cache.fetch(CACHE_KEY) { current_and_future_messages.to_a }
messages = Rails.cache.fetch(CACHE_KEY, expires_in: cache_expires_in) { current_and_future_messages.to_a }
return messages if messages.empty?
@ -36,6 +36,10 @@ class BroadcastMessage < ActiveRecord::Base
where('ends_at > :now', now: Time.zone.now).order_id_asc
end
def self.cache_expires_in
nil
end
def active?
started? && !ended?
end

View File

@ -51,7 +51,11 @@ describe BroadcastMessage do
expect(described_class).to receive(:where).and_call_original.once
2.times { described_class.current }
described_class.current
Timecop.travel(1.year) do
described_class.current
end
end
it 'includes messages that need to be displayed in the future' do