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
This commit is contained in:
Nick Thomas 2018-04-11 19:04:10 +00:00
commit 84c70f4335
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