Module: Mongoid::QueryCache::Query

Extended by:
ActiveSupport::Concern
Includes:
Cacheable
Defined in:
lib/mongoid/query_cache.rb

Overview

Adds behaviour around caching to a Moped Query object.

Since:

  • 4.0.0

Instance Method Summary collapse

Instance Method Details

#cursor_with_cacheCachedCursor

Provide a wrapped query cache cursor.

Examples:

Get the wrapped caching cursor.

query.cursor_with_cache

Returns:

Since:

  • 4.0.0



177
178
179
# File 'lib/mongoid/query_cache.rb', line 177

def cursor_with_cache
  CachedCursor.new(session, operation)
end

#first_with_cacheHash

Override first with caching.

Examples:

Get the first with a cache.

query.first_with_cache

Returns:

  • (Hash)

    The first document.

Since:

  • 4.0.0



189
190
191
192
193
# File 'lib/mongoid/query_cache.rb', line 189

def first_with_cache
  with_cache(:first) do
    first_without_cache
  end
end