Module: SemanticCache::Cacheable::ClassMethods

Defined in:
lib/semantic_cache/rails.rb

Instance Method Summary collapse

Instance Method Details

#cache_ai_calls(only: nil, except: nil, ttl: nil, namespace: nil) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/semantic_cache/rails.rb', line 49

def cache_ai_calls(only: nil, except: nil, ttl: nil, namespace: nil)
  actions = { only: only, except: except }.compact

  around_action(**actions) do |_controller, block|
    SemanticCache.with_cache(namespace: namespace, default_ttl: ttl) do
      block.call
    end
  end
end