module Mongoid::QueryCache::Query

Adds behaviour around caching to a Moped Query object.

@since 4.0.0

Public Instance Methods

cursor_with_cache() click to toggle source

Provide a wrapped query cache cursor.

@example Get the wrapped caching cursor.

query.cursor_with_cache

@return [ CachedCursor ] The cached cursor.

@since 4.0.0

# File lib/mongoid/query_cache.rb, line 172
def cursor_with_cache
  CachedCursor.new(session, operation)
end
first_with_cache() click to toggle source

Override first with caching.

@example Get the first with a cache.

query.first_with_cache

@return [ Hash ] The first document.

@since 4.0.0

# File lib/mongoid/query_cache.rb, line 184
def first_with_cache
  with_cache(:first) do
    first_without_cache
  end
end

Private Instance Methods

cache_key() click to toggle source
# File lib/mongoid/query_cache.rb, line 192
def cache_key
  [ operation.database, operation.collection, operation.selector, operation.limit, operation.skip, operation.fields ]
end
system_collection?() click to toggle source
# File lib/mongoid/query_cache.rb, line 196
def system_collection?
  operation.collection =~ /^system./
end