Module: Mongoid::QueryCache
- Defined in:
- lib/mongoid/query_cache.rb
Overview
A cache of database queries on a per-request basis.
Constant Summary collapse
- Middleware =
Mongo::QueryCache::Middleware
Class Method Summary collapse
-
.cache(&block) ⇒ Object
Execute the block while using the query cache.
-
.clear_cache ⇒ nil
Clear the query cache.
-
.enabled=(value) ⇒ Object
Set whether the cache is enabled.
-
.enabled? ⇒ true | false
Is the query cache enabled on the current thread?.
-
.uncached(&block) ⇒ Object
Execute the block with the query cache disabled.
Class Method Details
.cache(&block) ⇒ Object
Execute the block while using the query cache.
46 47 48 |
# File 'lib/mongoid/query_cache.rb', line 46 def cache(&block) Mongo::QueryCache.cache(&block) end |
.clear_cache ⇒ nil
Clear the query cache.
16 17 18 |
# File 'lib/mongoid/query_cache.rb', line 16 def clear_cache Mongo::QueryCache.clear end |
.enabled=(value) ⇒ Object
Set whether the cache is enabled.
26 27 28 |
# File 'lib/mongoid/query_cache.rb', line 26 def enabled=(value) Mongo::QueryCache.enabled = value end |
.enabled? ⇒ true | false
Is the query cache enabled on the current thread?
36 37 38 |
# File 'lib/mongoid/query_cache.rb', line 36 def enabled? Mongo::QueryCache.enabled? end |
.uncached(&block) ⇒ Object
Execute the block with the query cache disabled.
56 57 58 |
# File 'lib/mongoid/query_cache.rb', line 56 def uncached(&block) Mongo::QueryCache.uncached(&block) end |