Sha256: 117efc0e8d5c590f35f3149df8d1f8f655c6512bdd13d99efa1e6cd09f4ed21a

Contents?: true

Size: 622 Bytes

Versions: 5

Compression:

Stored size: 622 Bytes

Contents

# frozen_string_literal: true

module SecondLevelCache
  module ActiveRecord
    module Base
      def self.prepended(base)
        base.after_commit :update_second_level_cache, on: :update
        base.after_commit :write_second_level_cache, on: :create
        base.after_commit :expire_second_level_cache, on: :destroy

        class << base
          prepend ClassMethods
        end
      end

      module ClassMethods
        def update_counters(id, counters)
          super(id, counters).tap do
            Array(id).each { |i| expire_second_level_cache(i) }
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
second_level_cache-2.7.1 lib/second_level_cache/active_record/base.rb
second_level_cache-2.7.0 lib/second_level_cache/active_record/base.rb
second_level_cache-2.6.4 lib/second_level_cache/active_record/base.rb
second_level_cache-2.6.3 lib/second_level_cache/active_record/base.rb
second_level_cache-2.6.2 lib/second_level_cache/active_record/base.rb