Commit 84c70f43 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'mk/geo/backport-broadcast-message-cache-expiration-hook' into 'master'

[CE Backport] Propagate broadcast messages to secondaries

See merge request gitlab-org/gitlab-ce!18324
parents 9f8d91c9 1ce0595b
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment