Sha256: 8d6fde5da8e805727e50aacc6a2962d9f914e58c1791a8520fd5058a9b335eac

Contents?: true

Size: 871 Bytes

Versions: 170

Compression:

Stored size: 871 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:

  # Adds support for caching queries at the class level.
  module Extras
    extend ActiveSupport::Concern

    included do
      class_attribute :cached
      self.cached = false
    end

    module ClassMethods #:nodoc

      # Sets caching on for this class. This class level configuration will
      # default all queries to cache the results of the first iteration over
      # the cursor into an internal array. This should only be used for queries
      # that return a small number of results or have small documents, as after
      # the first iteration the entire results will be stored in memory.
      #
      # @example Cache all reads for the class.
      #   class Person
      #     include Mongoid::Document
      #     cache
      #   end
      def cache
        self.cached = true
      end
    end
  end
end

Version data entries

170 entries across 78 versions & 4 rubygems

Version Path
classiccms-0.3.7 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extras.rb
classiccms-0.3.7 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extras.rb
classiccms-0.3.7 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extras.rb
classiccms-0.3.6 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extras.rb
classiccms-0.3.6 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extras.rb
classiccms-0.3.6 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extras.rb
classiccms-0.3.5 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extras.rb
classiccms-0.3.5 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extras.rb
classiccms-0.3.5 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extras.rb
mongoid-2.4.11 lib/mongoid/extras.rb
classiccms-0.3.4 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extras.rb
classiccms-0.3.4 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extras.rb
classiccms-0.3.4 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extras.rb
classiccms-0.3.3 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extras.rb
classiccms-0.3.3 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extras.rb
classiccms-0.3.3 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extras.rb
classiccms-0.3.2 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extras.rb
classiccms-0.3.2 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extras.rb
classiccms-0.3.2 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extras.rb
classiccms-0.3.1 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extras.rb