Sha256: cdd97ba6bcbda2ee5da1ee94147c92fff93168888265c009114a392fccd6f7f2
Contents?: true
Size: 1.74 KB
Versions: 1
Compression:
Stored size: 1.74 KB
Contents
require 'glue/aspects' module Glue # This module adds cleanup functionality to managed # classes. Override and implement sweep_affected. # Typically used to cleanup output caching files from # the filesystem. But you can also use it to clean up # temp objects in the database or other temp files. #-- # FIXME: find a better name. #++ module Sweeper include Glue::Aspects before "sweep_affected(:insert)", :on => :og_insert before "sweep_affected(:update)", :on => :og_update before "sweep_affected(:delete)", :on => :og_delete #-- # FIXME: replace with 'extend Nitro::Caching::Output' ? # If you change this method, don't forget the Caching::Output # expire method. #++ def self.expire(name) begin Logger.debug "Sweeper expired cache file '#{Server.public_root}/#{name}'" if $DBG FileUtils.rm_rf("#{Server.public_root}/#{name}") rescue Object # gmosx: is this the right thing to do? end end private # If needed pass the calling action symbol to allow # for conditional expiration. # Action takes values from { :insert, :delete, :update } # or your own custom enumeration. # # Generally add lines like the following: # # expire_affected_output('file_to_expire') def sweep_affected(action = :all) end alias_method :expire_affected, :sweep_affected #-- # Generally you don't override this. #++ def expire_affected_output(name) Sweeper.expire(name) end alias_method :expire_output, :expire_affected_output # Expire affected cached fragments. def expire_affected_fragment(name, options = {}) Nitro::Caching::Fragments.cache.delete(name, options) end alias_method :expire_fragment, :expire_affected_fragment end end # * George Moschovitis <gm@navel.gr>
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.29.0 | lib/glue/sweeper.rb |