Class: Heartcheck::CachingApp::Cache
- Inherits:
-
Object
- Object
- Heartcheck::CachingApp::Cache
- Defined in:
- lib/heartcheck/caching_app/cache.rb
Overview
This cache performs the given controllers in background threads.
The public interface always queries the results from the cache.
Instance Attribute Summary collapse
-
#concurrent_opts ⇒ Object
Returns the value of attribute concurrent_opts.
Instance Method Summary collapse
-
#initialize(controllers, ttl) ⇒ Cache
constructor
A new instance of Cache.
-
#result(controller) ⇒ String
Fetches the current result for the given controller.
- #start ⇒ Object
Constructor Details
#initialize(controllers, ttl) ⇒ Cache
Returns a new instance of Cache.
15 16 17 18 19 20 |
# File 'lib/heartcheck/caching_app/cache.rb', line 15 def initialize(controllers, ttl) @results = Concurrent::Map.new @controllers = controllers @ttl = ttl @concurrent_opts = {} end |
Instance Attribute Details
#concurrent_opts ⇒ Object
Returns the value of attribute concurrent_opts.
13 14 15 |
# File 'lib/heartcheck/caching_app/cache.rb', line 13 def concurrent_opts @concurrent_opts end |
Instance Method Details
#result(controller) ⇒ String
Fetches the current result for the given controller
27 28 29 |
# File 'lib/heartcheck/caching_app/cache.rb', line 27 def result(controller) @results[controller] end |
#start ⇒ Object
31 32 33 |
# File 'lib/heartcheck/caching_app/cache.rb', line 31 def start schedule(@ttl, &perform_all_controllers) end |