Class: Mongoid::QueryCache::CachedCursor Deprecated

Inherits:
Mongo::Cursor
  • Object
show all
Defined in:
build/mongoid-7.4/lib/mongoid/query_cache.rb

Overview

Deprecated.

This class is only used with driver versions 2.13 and lower.

A Cursor that attempts to load documents from memory first before hitting the database if the same query has already been executed.

Instance Method Summary collapse

Instance Method Details

#eachObject

We iterate over the cached documents if they exist already in the cursor otherwise proceed as normal.

Examples:

Iterate over the documents.

cursor.each do |doc|
  # ...
end


164
165
166
167
168
169
170
171
172
# File 'build/mongoid-7.4/lib/mongoid/query_cache.rb', line 164

def each
  if @cached_documents
    @cached_documents.each do |doc|
      yield doc
    end
  else
    super
  end
end

#inspectString

Get a human-readable string representation of Cursor.

Examples:

Inspect the cursor.

cursor.inspect

Returns:

  • (String)

    A string representation of a Cursor instance.



180
181
182
# File 'build/mongoid-7.4/lib/mongoid/query_cache.rb', line 180

def inspect
  "#<Mongoid::QueryCache::CachedCursor:0x#{object_id} @view=#{@view.inspect}>"
end