Module: Workarea::Elasticsearch::QueryCache
- Defined in:
- lib/workarea/elasticsearch/query_cache.rb
Defined Under Namespace
Modules: Client Classes: Middleware
Class Method Summary collapse
-
.cache ⇒ Object
Execute the block while using the query cache.
-
.cache_table ⇒ Hash
Get the cached queries.
-
.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 ⇒ Object
Execute the block with the query cache disabled.
Class Method Details
.cache ⇒ Object
Execute the block while using the query cache.
53 54 55 56 57 58 59 |
# File 'lib/workarea/elasticsearch/query_cache.rb', line 53 def cache enabled = QueryCache.enabled? QueryCache.enabled = true yield ensure QueryCache.enabled = enabled end |
.cache_table ⇒ Hash
Get the cached queries.
13 14 15 |
# File 'lib/workarea/elasticsearch/query_cache.rb', line 13 def cache_table self.query_cache ||= {} end |
.clear_cache ⇒ nil
Clear the query cache.
23 24 25 |
# File 'lib/workarea/elasticsearch/query_cache.rb', line 23 def clear_cache self.query_cache = nil end |
.enabled=(value) ⇒ Object
Set whether the cache is enabled.
33 34 35 |
# File 'lib/workarea/elasticsearch/query_cache.rb', line 33 def enabled=(value) self.query_cache_enabled = value end |
.enabled? ⇒ true, false
Is the query cache enabled on the current thread?
43 44 45 |
# File 'lib/workarea/elasticsearch/query_cache.rb', line 43 def enabled? !!self.query_cache_enabled end |
.uncached ⇒ Object
Execute the block with the query cache disabled.
67 68 69 70 71 72 73 |
# File 'lib/workarea/elasticsearch/query_cache.rb', line 67 def uncached enabled = QueryCache.enabled? QueryCache.enabled = false yield ensure QueryCache.enabled = enabled end |