public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
insoshi / app / sweepers / activity_sweeper.rb
100644 20 lines (16 sloc) 0.449 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# This is currently unused, but a nice example of how to make a cache sweeper.
class ActivitySweeper < ActionController::Caching::Sweeper
  observe Activity
  
  def after_create(activity)
    clear_cache
  end
  
  def after_destroy(activity)
    clear_cache
  end
  
  private
  
    def clear_cache
      logger.info "cache sweep"
      expire_fragment(:controller => "home", :action => "index",
                      :part => "feed")
    end
end