8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/goodyear/query_cache.rb', line 8
def cache_query(query)
cache_key = sha(query)
Goodyear.force_cache
result = if store.exist?(cache_key) && Goodyear.force_cache
ActiveSupport::Notifications.instrument "cache.query.elasticsearch", name: self.name, query: query
store.fetch cache_key
else
res = []
ActiveSupport::Notifications.instrument "query.elasticsearch", name: self.name, query: query do
res = yield
end
store.write(cache_key, res) if Goodyear.force_cache
res
end
result.dup
end
|