Class: PagesCore::StaticCache::PageCacheHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/pages_core/static_cache/page_cache_handler.rb

Instance Method Summary collapse

Instance Method Details

#cache_page(controller, _request, _response) ⇒ Object



6
7
8
9
# File 'lib/pages_core/static_cache/page_cache_handler.rb', line 6

def cache_page(controller, _request, _response)
  controller.class.page_cache_directory = page_cache_directory
  controller.cache_page
end

#cache_page_permanently(controller, _request, _response) ⇒ Object



11
12
13
14
# File 'lib/pages_core/static_cache/page_cache_handler.rb', line 11

def cache_page_permanently(controller, _request, _response)
  controller.class.page_cache_directory = permanent_page_cache_directory
  controller.cache_page
end

#purge!Object



16
17
18
19
20
21
# File 'lib/pages_core/static_cache/page_cache_handler.rb', line 16

def purge!
  return unless PagesCore::CacheSweeper.enabled

  clear_directory(page_cache_directory)
  clear_directory(permanent_page_cache_directory)
end

#sweep!Object



23
24
25
26
27
# File 'lib/pages_core/static_cache/page_cache_handler.rb', line 23

def sweep!
  return unless PagesCore::CacheSweeper.enabled

  PagesCore::SweepCacheJob.perform_later
end

#sweep_now!Object



29
30
31
32
33
# File 'lib/pages_core/static_cache/page_cache_handler.rb', line 29

def sweep_now!
  return unless PagesCore::CacheSweeper.enabled

  clear_directory(page_cache_directory)
end