Class: RailsAiBridge::CacheWarmer
- Inherits:
-
Object
- Object
- RailsAiBridge::CacheWarmer
- Defined in:
- lib/rails_ai_bridge/cache_warmer.rb
Overview
Pre-populates the introspection cache during Rails boot.
Calling +.warm+ triggers a full introspection pass so that the first MCP tool call returns instantly from cache rather than blocking on a cold introspection. Errors are logged and swallowed — warming is best-effort and must never prevent the app from starting.
Class Method Summary collapse
-
.warm(app = Rails.application) ⇒ void
Warms the full introspection cache for +app+.
-
.warm_sections(sections, app = Rails.application) ⇒ void
Warms individual section caches for the given introspector keys.
Class Method Details
.warm(app = Rails.application) ⇒ void
This method returns an undefined value.
Warms the full introspection cache for +app+.
16 17 18 19 20 |
# File 'lib/rails_ai_bridge/cache_warmer.rb', line 16 def warm(app = Rails.application) ContextProvider.fetch(app) rescue StandardError => error log_warning("cache warming failed: #{error.}") end |
.warm_sections(sections, app = Rails.application) ⇒ void
This method returns an undefined value.
Warms individual section caches for the given introspector keys.
27 28 29 30 31 32 33 |
# File 'lib/rails_ai_bridge/cache_warmer.rb', line 27 def warm_sections(sections, app = Rails.application) sections.each do |section| ContextProvider.fetch_section(section, app) rescue StandardError => error log_warning("section #{section} warming failed: #{error.}") end end |