Merge pull request from GHSA-qg32-3vrh-w6mw

This commit is contained in:
KMY(雪あすか) 2023-12-15 09:41:22 +09:00 committed by KMY
parent e9b69478d1
commit e8b6c16b52
2 changed files with 37 additions and 4 deletions

View file

@ -180,6 +180,16 @@ module CacheConcern
def render_with_cache(**options)
raise ArgumentError, 'Only JSON render calls are supported' unless options.key?(:json) || block_given?
if options.delete(:cancel_cache)
if block_given?
options[:json] = yield
elsif options[:json].is_a?(Symbol)
options[:json] = send(options[:json])
end
return render(options)
end
key = options.delete(:key) || [[params[:controller], params[:action]].join('/'), options[:json].respond_to?(:cache_key) ? options[:json].cache_key : nil, options[:fields].nil? ? nil : options[:fields].join(',')].compact.join(':')
expires_in = options.delete(:expires_in) || 3.minutes
body = Rails.cache.read(key, raw: true)