Sha256: 93df056cb3e7df3275b12f6445b30d3ed0b098a216df232c858ed55dabe08f04

Contents?: true

Size: 553 Bytes

Versions: 5

Compression:

Stored size: 553 Bytes

Contents

module Blacksand
  module ExpirePages
    extend ActiveSupport::Concern
    
    included do
      after_action :expire_cache_pages, only: [:create, :update, :destroy]
    end


    def expire_cache_pages
      if defined? Rails.application.routes.url_helpers.root_path
        expire_page Rails.application.routes.url_helpers.root_path
      end

      # TODO: 有点暴力, 可以扫描缓存文件夹,挨个删除
      Blacksand::Page.find_each do |p|
        expire_page Rails.application.routes.url_helpers.page_path(p)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
blacksand-2.5.0 lib/blacksand/expire_pages.rb
blacksand-2.4.1 lib/blacksand/expire_pages.rb
blacksand-2.4.0 lib/blacksand/expire_pages.rb
blacksand-2.3.0 lib/blacksand/expire_pages.rb
blacksand-2.2.2.1 lib/blacksand/expire_pages.rb