Module: Motor::Alerts::ScheduledAlertsCache

Defined in:
lib/motor/alerts/scheduled_alerts_cache.rb

Constant Summary collapse

CACHE_STORE =
ActiveSupport::Cache::MemoryStore.new(size: 5.megabytes)

Class Method Summary collapse

Class Method Details

.allObject


10
11
12
13
14
15
16
17
18
# File 'lib/motor/alerts/scheduled_alerts_cache.rb', line 10

def all
  ActiveRecord::Base.logger.silence do
    CACHE_STORE.fetch(Motor::Alert.all.maximum(:updated_at)) do
      clear

      Motor::Alert.all.active.enabled.to_a
    end
  end
end

.clearObject


20
21
22
# File 'lib/motor/alerts/scheduled_alerts_cache.rb', line 20

def clear
  CACHE_STORE.clear
end