Class: Tasker::DetectorRegistry
- Inherits:
-
Object
- Object
- Tasker::DetectorRegistry
- Includes:
- Singleton
- Defined in:
- lib/tasker/cache_strategy.rb
Overview
Singleton registry for managing custom detectors and caching strategies
Instance Method Summary collapse
- #cache_strategy_for(store_class_name, strategy_instance) ⇒ Object
-
#cached_strategy_for(store_class_name) ⇒ Object
Cache strategy instances for performance.
-
#clear_detectors! ⇒ Object
Clear all registered detectors (primarily for testing).
-
#custom_detectors ⇒ Object
Get custom detectors (thread-safe read access).
-
#initialize ⇒ DetectorRegistry
constructor
A new instance of DetectorRegistry.
-
#register_detector(pattern, detector) ⇒ Object
Register a custom cache store detector.
Constructor Details
#initialize ⇒ DetectorRegistry
Returns a new instance of DetectorRegistry.
426 427 428 429 430 |
# File 'lib/tasker/cache_strategy.rb', line 426 def initialize @custom_detectors = {} @strategy_cache = {} @cache_mutex = Mutex.new end |
Instance Method Details
#cache_strategy_for(store_class_name, strategy_instance) ⇒ Object
463 464 465 466 467 |
# File 'lib/tasker/cache_strategy.rb', line 463 def cache_strategy_for(store_class_name, strategy_instance) @cache_mutex.synchronize do @strategy_cache[store_class_name] = strategy_instance end end |
#cached_strategy_for(store_class_name) ⇒ Object
Cache strategy instances for performance
457 458 459 460 461 |
# File 'lib/tasker/cache_strategy.rb', line 457 def cached_strategy_for(store_class_name) @cache_mutex.synchronize do @strategy_cache[store_class_name] end end |
#clear_detectors! ⇒ Object
Clear all registered detectors (primarily for testing)
444 445 446 447 448 449 |
# File 'lib/tasker/cache_strategy.rb', line 444 def clear_detectors! @cache_mutex.synchronize do @custom_detectors.clear @strategy_cache.clear end end |
#custom_detectors ⇒ Object
Get custom detectors (thread-safe read access)
452 453 454 |
# File 'lib/tasker/cache_strategy.rb', line 452 def custom_detectors @cache_mutex.synchronize { @custom_detectors.dup } end |
#register_detector(pattern, detector) ⇒ Object
Register a custom cache store detector
436 437 438 439 440 441 |
# File 'lib/tasker/cache_strategy.rb', line 436 def register_detector(pattern, detector) @cache_mutex.synchronize do @custom_detectors[pattern] = detector @strategy_cache.clear # Clear cache when detectors change end end |