Module: Mongoid::QueryCache::View
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/mongoid/query_cache.rb
Overview
Contains enhancements to the Mongo::Collection::View in order to get a cached cursor or a regular cursor on iteration.
Instance Method Summary collapse
-
#each ⇒ Object
Override the default enumeration to handle if the cursor can be cached or not.
Instance Method Details
#each ⇒ Object
Override the default enumeration to handle if the cursor can be cached or not.
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/mongoid/query_cache.rb', line 219 def each if system_collection? || !QueryCache.enabled? super else unless cursor = cached_cursor server = read_or_server_selector.select_server(cluster) cursor = CachedCursor.new(view, send_initial_query(server), server) QueryCache.cache_table[cache_key] = cursor end cursor.each do |doc| yield doc end if block_given? cursor end end |