Sha256: 15e2dc3d93093345993536d9e4cb2875d9ac00179439b9ea1a57bd4daf596d66

Contents?: true

Size: 595 Bytes

Versions: 2

Compression:

Stored size: 595 Bytes

Contents

# frozen_string_literal: true

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

      module_function

      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

      def clear
        CACHE_STORE.clear
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
motor-admin-0.1.51 lib/motor/alerts/scheduled_alerts_cache.rb
motor-admin-0.1.50 lib/motor/alerts/scheduled_alerts_cache.rb