Commit be6c72dc authored by Ryan Cobb's avatar Ryan Cobb

Add ability to run reactive caching synchronously

parent 2efd3a0a
......@@ -106,6 +106,8 @@ module ReactiveCaching
end
def with_reactive_cache(*args, &blk)
return reactive_cache_pry(*args, &blk) if ENV['REACTIVE_CACHE_PRY'] == 'true'
unless within_reactive_cache_lifetime?(*args)
refresh_reactive_cache!(*args)
return
......@@ -146,6 +148,14 @@ module ReactiveCaching
private
def reactive_cache_pry(*args, &blk)
data = Rails.cache.fetch(full_reactive_cache_key(*args), expires_in: 5.seconds) do
self.class.reactive_cache_worker_finder.call(id, *args).calculate_reactive_cache(*args)
end
yield data
end
def refresh_reactive_cache!(*args)
clear_reactive_cache!(*args)
keep_alive_reactive_cache!(*args)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment