mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Replace middleware with executor callback.
Per request digest caches were added before we had hooks into different units of work that Rails performs. As such the most reliable way to prevent stale cache digests was with a middleware. The middleware prevented staleness in Action Controller requests. However, the executor is superior because it should also prevent staleness when running just Active Job jobs or broadcasting through Action Cable's server.
This commit is contained in:
parent
8fffee4b1c
commit
23b6a9c0fc
2 changed files with 1 additions and 8 deletions
|
@ -6,13 +6,6 @@ module ActionView
|
|||
class Digestor
|
||||
@@digest_mutex = Mutex.new
|
||||
|
||||
class PerRequestDigestCacheExpiry < Struct.new(:app) # :nodoc:
|
||||
def call(env)
|
||||
ActionView::LookupContext::DetailsKey.clear
|
||||
app.call(env)
|
||||
end
|
||||
end
|
||||
|
||||
class << self
|
||||
# Supported options:
|
||||
#
|
||||
|
|
|
@ -40,7 +40,7 @@ module ActionView
|
|||
initializer "action_view.per_request_digest_cache" do |app|
|
||||
ActiveSupport.on_load(:action_view) do
|
||||
if app.config.consider_all_requests_local
|
||||
app.middleware.use ActionView::Digestor::PerRequestDigestCacheExpiry
|
||||
app.executor.to_run { ActionView::LookupContext::DetailsKey.clear }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue