diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2016-05-16 21:34:16 +0200 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2016-05-16 21:34:16 +0200 |
commit | 23b6a9c0fcb8992e18450d6fe0680bf09685b7db (patch) | |
tree | 6d04277ef922685b87a7621c6bcb503b2a866962 /actionview/lib | |
parent | 8fffee4b1cd7f742edb267d72f4007d0ed4c594b (diff) | |
download | rails-23b6a9c0fcb8992e18450d6fe0680bf09685b7db.tar.gz rails-23b6a9c0fcb8992e18450d6fe0680bf09685b7db.tar.bz2 rails-23b6a9c0fcb8992e18450d6fe0680bf09685b7db.zip |
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.
Diffstat (limited to 'actionview/lib')
-rw-r--r-- | actionview/lib/action_view/digestor.rb | 7 | ||||
-rw-r--r-- | actionview/lib/action_view/railtie.rb | 2 |
2 files changed, 1 insertions, 8 deletions
diff --git a/actionview/lib/action_view/digestor.rb b/actionview/lib/action_view/digestor.rb index b99d1af998..53baf044f1 100644 --- a/actionview/lib/action_view/digestor.rb +++ b/actionview/lib/action_view/digestor.rb @@ -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: # diff --git a/actionview/lib/action_view/railtie.rb b/actionview/lib/action_view/railtie.rb index c83614c89a..dfb99f4ea9 100644 --- a/actionview/lib/action_view/railtie.rb +++ b/actionview/lib/action_view/railtie.rb @@ -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 |