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 = nil) ⇒ void
Warms the full introspection cache for
app. -
.warm_sections(sections, app = nil) ⇒ void
Warms individual section caches for the given introspector keys.
Class Method Details
.warm(app = nil) ⇒ void
This method returns an undefined value.
Warms the full introspection cache for app.
16 17 18 19 20 21 |
# File 'lib/rails_ai_bridge/cache_warmer.rb', line 16 def warm(app = nil) app ||= AppScope.current_app ContextProvider.fetch(app) rescue StandardError => error log_warning("cache warming failed: #{error.}") end |
.warm_sections(sections, app = nil) ⇒ void
This method returns an undefined value.
Warms individual section caches for the given introspector keys.
28 29 30 31 32 33 34 35 |
# File 'lib/rails_ai_bridge/cache_warmer.rb', line 28 def warm_sections(sections, app = nil) app ||= AppScope.current_app sections.each do |section| ContextProvider.fetch_section(section, app) rescue StandardError => error log_warning("section #{section} warming failed: #{error.}") end end |