Method: Mongo::QueryCache.cache

Defined in:
lib/mongo/query_cache.rb

.cacheObject

Execute the block while using the query cache.

Examples:

Execute with the cache.

QueryCache.cache { collection.find }

Returns:

  • (Object)

    The result of the block.



48
49
50
51
52
53
54
55
56
# File 'lib/mongo/query_cache.rb', line 48

def cache
  enabled = enabled?
  self.enabled = true
  begin
    yield
  ensure
    self.enabled = enabled
  end
end