diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-01-30 11:31:15 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-01-30 11:31:15 +0000 |
commit | 55c4996b4d9f737a53f2a3c5b4d3449f5f5cba96 (patch) | |
tree | 9801d8670802d9c6f5e65c4647eb0e7a80b27f6c /app | |
parent | f862b4ae0faee80344faa583c74389c8e57fb7c2 (diff) | |
parent | a6d6cfaf924f8002e807fda9bad03e866db2a4ec (diff) | |
download | gitlab-ce-55c4996b4d9f737a53f2a3c5b4d3449f5f5cba96.tar.gz |
Merge branch 'cache-broadcast-message-current' into 'master'
Cache BroadcastMessage.current. Fixes #12770
See merge request !2633
Diffstat (limited to 'app')
-rw-r--r-- | app/models/broadcast_message.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/broadcast_message.rb b/app/models/broadcast_message.rb index 61119633717..8a0a8a4c2a9 100644 --- a/app/models/broadcast_message.rb +++ b/app/models/broadcast_message.rb @@ -26,7 +26,9 @@ class BroadcastMessage < ActiveRecord::Base default_value_for :font, '#FFFFFF' def self.current - where("ends_at > :now AND starts_at <= :now", now: Time.zone.now).last + Rails.cache.fetch("broadcast_message_current", expires_in: 1.minute) do + where("ends_at > :now AND starts_at <= :now", now: Time.zone.now).last + end end def active? |