Sha256: 2021edc73d0e9190dcb6c13c70e2a31b7cfb20ba1cb26ecd1e77ed8494cce31a

Contents?: true

Size: 797 Bytes

Versions: 40

Compression:

Stored size: 797 Bytes

Contents

require 'active_support/core_ext/object/blank'

module ActiveRecord
  # = Active Record Query Cache
  class QueryCache
    module ClassMethods
      # Enable the query cache within the block if Active Record is configured.
      def cache(&block)
        if ActiveRecord::Base.configurations.blank?
          yield
        else
          connection.cache(&block)
        end
      end

      # Disable the query cache within the block if Active Record is configured.
      def uncached(&block)
        if ActiveRecord::Base.configurations.blank?
          yield
        else
          connection.uncached(&block)
        end
      end
    end

    def initialize(app)
      @app = app
    end

    def call(env)
      ActiveRecord::Base.cache do
        @app.call(env)
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 2 rubygems

Version Path
activerecord-3.0.20 lib/active_record/query_cache.rb
activerecord-3.0.19 lib/active_record/query_cache.rb
activerecord-3.0.18 lib/active_record/query_cache.rb
activerecord-3.0.17 lib/active_record/query_cache.rb
activerecord-3.0.16 lib/active_record/query_cache.rb
activerecord-3.0.15 lib/active_record/query_cache.rb
activerecord-3.0.14 lib/active_record/query_cache.rb
activerecord-3.0.13 lib/active_record/query_cache.rb
activerecord-3.0.13.rc1 lib/active_record/query_cache.rb
activerecord-3.0.12 lib/active_record/query_cache.rb
activerecord-3.0.12.rc1 lib/active_record/query_cache.rb
activerecord-3.0.11 lib/active_record/query_cache.rb
activerecord-3.0.10 lib/active_record/query_cache.rb
activerecord-3.0.10.rc1 lib/active_record/query_cache.rb
activerecord-3.0.9 lib/active_record/query_cache.rb
activerecord-3.0.9.rc5 lib/active_record/query_cache.rb
activerecord-3.0.9.rc4 lib/active_record/query_cache.rb
activerecord-3.0.9.rc3 lib/active_record/query_cache.rb
activerecord-3.0.9.rc1 lib/active_record/query_cache.rb
activerecord-3.0.8 lib/active_record/query_cache.rb