Sha256: 2073ad723cc28a076b6ff6e47540e178abe2e3eb826a638f4552cd80bca30619

Contents?: true

Size: 622 Bytes

Versions: 2

Compression:

Stored size: 622 Bytes

Contents

# frozen_string_literal: true

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

        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

2 entries across 2 versions & 1 rubygems

Version Path
second_level_cache-2.4.1 lib/second_level_cache/active_record/base.rb
second_level_cache-2.4.0 lib/second_level_cache/active_record/base.rb