lib/glue/sweeper.rb in nitro-0.30.0 vs lib/glue/sweeper.rb in nitro-0.31.0
- old
+ new
@@ -10,26 +10,30 @@
#--
# FIXME: find a better name.
#++
module Sweeper
- include ::Aspects
+ include Aspects
before "sweep_affected(:insert)", :on => :og_insert
before "sweep_affected(:update)", :on => :og_update
before "sweep_affected(:delete)", :on => :og_delete
+ # Expires (deletes) a cached page from the file system.
#--
# FIXME: replace with 'extend Nitro::Caching::Output' ?
+ # this way we wont have to sync the same code in two different
+ # places.
# If you change this method, don't forget the Caching::Output
# expire method.
#++
- def self.expire(name)
+ def self.expire(name, klass)
begin
- Logger.debug "Sweeper expired cache file '#{Server.public_root}/#{name}'" if $DBG
- FileUtils.rm_rf("#{Server.public_root}/#{name}")
+ filename = "#{Server.public_root}/#{klass.ann.self.controller.mount_path}/#{name}".squeeze('/')
+ Logger.debug "Sweeper expired cache file '#{filename}'" if $DBG
+ FileUtils.rm_rf(filename)
rescue Object
# gmosx: is this the right thing to do?
end
end
@@ -51,10 +55,10 @@
#--
# Generally you don't override this.
#++
def expire_affected_output(name)
- Sweeper.expire(name)
+ Sweeper.expire(name, self.class)
end
alias_method :expire_output, :expire_affected_output
# Expire affected cached fragments.