Sha256: ef4035ba2e56c95587e6a46215669d83317ad8681ea3042324b214744ad3beb9
Contents?: true
Size: 1.25 KB
Versions: 21
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true module PagesCore module StaticCache class PageCacheHandler def cache_page(controller, _request, _response) controller.class.page_cache_directory = page_cache_directory controller.cache_page end def cache_page_permanently(controller, _request, _response) controller.class.page_cache_directory = permanent_page_cache_directory controller.cache_page end def purge! return unless PagesCore::CacheSweeper.enabled clear_directory(page_cache_directory) clear_directory(permanent_page_cache_directory) end def sweep! return unless PagesCore::CacheSweeper.enabled PagesCore::SweepCacheJob.perform_later end def sweep_now! return unless PagesCore::CacheSweeper.enabled clear_directory(page_cache_directory) end private def cache_root Rails.public_path end def clear_directory(path) return unless File.exist?(path) FileUtils.rm_rf(Dir.glob("#{path}/*")) end def page_cache_directory cache_root.join("static_cache") end def permanent_page_cache_directory cache_root.join("cache") end end end end
Version data entries
21 entries across 21 versions & 1 rubygems