Class: ActionView::CacheExpiry::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/action_view/cache_expiry.rb

Instance Method Summary collapse

Constructor Details

#initialize(watcher:) ⇒ Executor

Returns a new instance of Executor.



6
7
8
9
10
11
# File 'lib/action_view/cache_expiry.rb', line 6

def initialize(watcher:)
  @execution_lock = Concurrent::ReentrantReadWriteLock.new
  @cache_expiry = ViewModificationWatcher.new(watcher: watcher) do
    clear_cache
  end
end

Instance Method Details

#complete(_) ⇒ Object



20
21
22
# File 'lib/action_view/cache_expiry.rb', line 20

def complete(_)
  @execution_lock.release_read_lock
end

#runObject



13
14
15
16
17
18
# File 'lib/action_view/cache_expiry.rb', line 13

def run
  ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
    @cache_expiry.execute_if_updated
    @execution_lock.acquire_read_lock
  end
end