Module: RailsAi::Cache
- Defined in:
- lib/rails_ai/cache.rb
Class Method Summary collapse
Class Method Details
.fetch(key, **opts, &block) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/rails_ai/cache.rb', line 5 def self.fetch(key, **opts, &block) if defined?(Rails) && Rails.cache Rails.cache.fetch([:rails_ai, key], {expires_in: RailsAi.config.cache_ttl}.merge(opts), &block) elsif block_given? # Fallback for when Rails cache is not available (e.g., in tests) block.call end end |