padrino/padrino-framework · error
Can not provide both cache_key and a block
Error message
Can not provide both cache_key and a block
What it means
Error "Can not provide both cache_key and a block" thrown in padrino/padrino-framework.
Source
Thrown at padrino-cache/lib/padrino-cache/helpers/page.rb:91
#
# @example
# controller '/blog', cache: true do
#
# get '/post/:id' do
# cache_key :my_name
# @post = Post.find(params[:id])
# end
# end
#
# @example
# get '/foo', cache: true do
# cache_key { param[:id] }
# "My id is #{param[:id}"
# end
# end
#
def cache_key(name = nil, &block)
raise 'Can not provide both cache_key and a block' if name && block
@route.cache_key = name || block
end
CACHED_VERBS = { 'GET' => true, 'HEAD' => true }.freeze
def self.padrino_route_added(route, verb, *)
return unless route.cache && CACHED_VERBS[verb]
route.before_filters do
next unless settings.caching?
if (cached_response = load_cached_response)
content_type cached_response[:content_type]
halt 200, cached_response[:body]
end
end
route.after_filters do
save_cached_response(route.cache_expires) if settings.caching?View on GitHub (pinned to 167044f3d5)
When it happens
Trigger: Thrown at padrino-cache/lib/padrino-cache/helpers/page.rb:91 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of padrino/padrino-framework@167044f3d5 (2026-08-23).
Data as JSON: /api/errors/c650acb92e07b57c.
Report an issue: GitHub.