Module: Cms::Caching

Included in:
Cms
Defined in:
lib/cms/caching.rb

Instance Method Summary collapse

Instance Method Details

#caching_enabled?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/cms/caching.rb', line 3

def caching_enabled?
  ActionController::Base.perform_caching
end

#flush_cacheObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/cms/caching.rb', line 6

def flush_cache
  #Hmmm...this is kinda scary.  What if page cache directory is
  #set to the the default, which is /public?
  #So we are going to check that the directory is not called "public"
  if File.exists?(ActionController::Base.page_cache_directory) && 
      File.basename(ActionController::Base.page_cache_directory) != "public"
    FileUtils.rm_rf Dir.glob("#{ActionController::Base.page_cache_directory}/*")
    Rails.logger.info "Cache Flushed"
  end
end