Sha256: 1b0b7d695f8b51cf6067442c4e35878a897792aed2b86fae9bb35006e13ff67e

Contents?: true

Size: 616 Bytes

Versions: 11

Compression:

Stored size: 616 Bytes

Contents

class PageCache < ActiveRecord::Base
  cattr_accessor :public_path
  @@public_path = ActionController::Base.page_cache_directory

  def self.sweep(pattern)
    destroy_all("name like '#{pattern}'")
  end

  def self.sweep_all
    destroy_all
  end

  private

  after_destroy :expire_cache

  def expire_cache
    # It'd be better to call expire_page here, except it's a
    # controller method and we can't get to it.
    path = PageCache.public_path + "/#{self.name}"

    logger.info "Sweeping #{self.name}"
    delete_file(path)
  end

  def delete_file(path)
    File.delete(path) if File.file?(path)
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
typo-3.99.0 app/models/page_cache.rb
typo-3.99.2 app/models/page_cache.rb
typo-3.99.1 app/models/page_cache.rb
typo-3.99.3 app/models/page_cache.rb
typo-4.0.0 app/models/page_cache.rb
typo-3.99.4 app/models/page_cache.rb
typo-4.0.1 app/models/page_cache.rb
typo-4.0.2 app/models/page_cache.rb
typo-4.0.3 app/models/page_cache.rb
typo-4.1.1 app/models/page_cache.rb
typo-4.1 app/models/page_cache.rb