Sha256: 4c7603c95a2d5a9430fe6fbae1865eb082355b0cdb5fdd2347fac2262c8b2739

Contents?: true

Size: 565 Bytes

Versions: 9

Compression:

Stored size: 565 Bytes

Contents

# frozen_string_literal: true

module Motor
  module Alerts
    module ScheduledAlertsCache
      CACHE_STORE = ActiveSupport::Cache::MemoryStore.new(size: 5.megabytes)

      module_function

      def all
        ActiveRecord::Base.logger.silence do
          cache_key = Motor::Alert.maximum(:updated_at)

          return [] if cache_key.nil?

          CACHE_STORE.fetch(cache_key) do
            clear

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

      def clear
        CACHE_STORE.clear
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
motor-admin-cstham8-0.4.35 lib/motor/alerts/scheduled_alerts_cache.rb
motor-admin-cstham8-0.4.34 lib/motor/alerts/scheduled_alerts_cache.rb
motor-admin-cstham8-0.4.33 lib/motor/alerts/scheduled_alerts_cache.rb
motor-admin-cstham8-0.4.32 lib/motor/alerts/scheduled_alerts_cache.rb
motor-admin-cstham8-0.4.31 lib/motor/alerts/scheduled_alerts_cache.rb
motor-admin-cstham8-0.4.30 lib/motor/alerts/scheduled_alerts_cache.rb
motor-admin-cstham8-0.4.29 lib/motor/alerts/scheduled_alerts_cache.rb
motor-admin-cstham8-0.4.28 lib/motor/alerts/scheduled_alerts_cache.rb
motor-admin-cstham8-0.4.27 lib/motor/alerts/scheduled_alerts_cache.rb