Sha256: bf035909c679d6bc0ccd80edb513236b4125a7442804443c8d4ecf42f7ff8359

Contents?: true

Size: 952 Bytes

Versions: 5

Compression:

Stored size: 952 Bytes

Contents

module Refinery
  module PhotoGallery
    module Admin
      class PhotoSweeper < ActionController::Caching::Sweeper
        observe Photo

        def sweep(photo)
          # only file store supports regexp
          begin
            # TODO This is slow, but I was unable to get the actual cache folder path. 
            # This should be replaced with FileUtils.rm to get better speed
            expire_fragment( %r{refinery/photo_gallery/albums/#{photo.album_id}/page/\d*})
          rescue NotImplementedError
            Rails.cache.clear
            warn "**** [REFINERY PHOTO GALLERY] The cache store you are using is not compatible with this engine. Only file_store is supported. Clearing entire cache instead ***"
          ensure
            return true
          end
        end

        alias_method :after_create, :sweep
        alias_method :after_update, :sweep
        alias_method :after_destroy, :sweep
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
refinerycms-photo-gallery-0.3.0 app/sweepers/refinery/photo_gallery/admin/photo_sweeper.rb
refinerycms-photo-gallery-0.2.0 app/sweepers/refinery/photo_gallery/admin/photo_sweeper.rb
refinerycms-photo-gallery-0.1.2 app/sweepers/refinery/photo_gallery/admin/photo_sweeper.rb
refinerycms-photo-gallery-0.1.1 app/sweepers/refinery/photo_gallery/admin/photo_sweeper.rb
refinerycms-photo-gallery-0.1.0 app/sweepers/refinery/photo_gallery/admin/photo_sweeper.rb