Sha256: 727b28ad3bdb7c0fbb1a680f48e7fa31323294f360e4db205da94567cd837387

Contents?: true

Size: 655 Bytes

Versions: 1

Compression:

Stored size: 655 Bytes

Contents

module ActiveRecordMultipleQueryCache
  class Rails5QueryCache
    def initialize(active_record_base_class)
      activerecord_base_class = active_record_base_class.constantize if active_record_base_class.is_a?(String)

      @active_record_base_class = active_record_base_class
    end

    def run
      caching_pool = @active_record_base_class.connection_pool
      caching_was_enabled = caching_pool.query_cache_enabled

      caching_pool.enable_query_cache!

      [caching_pool, caching_was_enabled]
    end

    def complete((caching_pool, caching_was_enabled))
      caching_pool.disable_query_cache! unless caching_was_enabled
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_record_multiple_query_cache-0.1.0 lib/active_record_multiple_query_cache/rails5_query_cache.rb