Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap ActionView cache expiry in a mutex #36323

Merged
merged 1 commit into from
May 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 11 additions & 8 deletions actionview/lib/action_view/cache_expiry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@ def initialize(watcher:)
@watched_dirs = nil
@watcher_class = watcher
@watcher = nil
@mutex = Mutex.new
end

def clear_cache_if_necessary
watched_dirs = dirs_to_watch
if watched_dirs != @watched_dirs
@watched_dirs = watched_dirs
@watcher = @watcher_class.new([], watched_dirs) do
clear_cache
@mutex.synchronize do
watched_dirs = dirs_to_watch
if watched_dirs != @watched_dirs
@watched_dirs = watched_dirs
@watcher = @watcher_class.new([], watched_dirs) do
clear_cache
end
@watcher.execute
else
@watcher.execute_if_updated
end
@watcher.execute
else
@watcher.execute_if_updated
end
end

Expand Down