public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
add cache sweeper logging

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@1554 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Mon Aug 07 23:01:56 -0700 2006
commit  76055a6b31eea7d21b57c572fae491dafd6ea935
tree    c31a7d776fcacd721ddf0c2c501e0a187d753635
parent  c2b527b7011f178b7d4c30a0ee649fbfbac3b8d4
...
1
 
2
3
4
...
9
10
11
12
13
14
15
 
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
...
1
2
3
4
5
...
10
11
12
 
 
 
 
13
14
15
16
 
 
 
 
 
 
 
 
 
 
 
 
 
17
18
0
@@ -1,4 +1,5 @@
0
 class ArticleSweeper < ActionController::Caching::Sweeper
0
+ include Mephisto::SweeperMethods
0
   observe Article
0
 
0
   def after_create(record)
0
@@ -9,24 +10,8 @@ class ArticleSweeper < ActionController::Caching::Sweeper
0
     return if controller.nil?
0
     expire_overview_feed! if record.is_a?(Article)
0
     pages = CachedPage.find_by_reference(record)
0
- controller.class.benchmark "Expired pages referenced by #{record.class} ##{record.id}" do
0
- pages.each { |p| controller.class.expire_page(p.url) }
0
- CachedPage.expire_pages(pages)
0
- end if pages.any?
0
+ expire_cached_pages "Expired pages referenced by #{record.class} ##{record.id}", *pages
0
   end
0
 
0
   alias after_destroy after_save
0
-
0
- protected
0
- def expire_overview_feed!
0
- controller.class.expire_page overview_url(:only_path => true, :skip_relative_url_root => true) if controller
0
- end
0
-
0
- def expire_assigned_sections!(record)
0
- record.send :save_assigned_sections
0
- record.sections.each do |section|
0
- controller.expire_page :sections => section.to_url, :controller => '/mephisto', :action => 'list'
0
- controller.expire_page :sections => section.to_feed_url, :controller => '/feed', :action => 'feed'
0
- end
0
- end
0
 end
0
\ No newline at end of file
...
1
 
2
3
4
5
6
7
8
9
 
10
11
12
13
...
1
2
3
4
5
6
 
 
 
 
7
8
9
10
11
0
@@ -1,12 +1,10 @@
0
 class AssetSweeper < ActionController::Caching::Sweeper
0
+ include Mephisto::SweeperMethods
0
   observe Resource
0
   def after_save(record)
0
     return if controller.nil?
0
     pages = CachedPage.find_by_reference(record)
0
- controller.class.benchmark "Expired pages referenced by #{record.class} ##{record.id}" do
0
- pages.each { |p| controller.class.expire_page(p.url) }
0
- CachedPage.expire_pages(pages)
0
- end if pages.any?
0
+ expire_cached_pages "Expired pages referenced by #{record.class} ##{record.id}", *pages
0
   end
0
   alias after_destroy after_save
0
 end
0
\ No newline at end of file
...
1
 
2
3
4
5
6
7
8
9
10
 
11
12
13
...
1
2
3
4
5
6
7
 
 
 
 
8
9
10
11
0
@@ -1,13 +1,11 @@
0
 class AssignedSectionSweeper < ActionController::Caching::Sweeper
0
+ include Mephisto::SweeperMethods
0
   observe AssignedSection
0
 
0
   def after_destroy(record)
0
     return if controller.nil?
0
     pages = CachedPage.find_by_reference_key('Section', record.section_id)
0
- controller.class.benchmark "Expired pages referenced by Section ##{record.section_id}" do
0
- pages.each { |p| controller.class.expire_page(p.url) }
0
- CachedPage.expire_pages(pages)
0
- end if pages.any?
0
+ expire_cached_pages "Expired pages referenced by Section ##{record.section_id}", *pages
0
   end
0
   
0
   alias after_create after_destroy
...
1
 
2
3
4
5
6
 
7
8
9
10
11
 
12
13
14
...
1
2
3
4
5
6
 
7
8
 
 
 
 
9
10
11
12
0
@@ -1,13 +1,11 @@
0
 class CommentSweeper < ActionController::Caching::Sweeper
0
+ include Mephisto::SweeperMethods
0
   observe Comment
0
 
0
   def after_update(record)
0
     return if controller.nil?
0
- controller.class.expire_page overview_url(:only_path => true, :skip_relative_url_root => true)
0
+ expire_overview_feed!
0
     pages = CachedPage.find_by_reference(record.article)
0
- controller.class.benchmark "Expired pages referenced by #{record.class} ##{record.id}" do
0
- pages.each { |p| controller.class.expire_page(p.url) }
0
- CachedPage.expire_pages(pages)
0
- end if pages.any?
0
+ expire_cached_pages "Expired pages referenced by #{record.class} ##{record.id}", *pages
0
   end
0
 end
0
\ No newline at end of file
...
1
2
 
3
4
5
...
1
2
3
4
5
6
0
@@ -1,4 +1,5 @@
0
 class SectionSweeper < ArticleSweeper
0
   observe Section
0
+
0
   undef :after_create
0
 end
0
\ No newline at end of file
...
1
 
2
3
4
...
8
9
10
11
12
13
14
15
 
16
17
18
...
1
2
3
4
5
...
9
10
11
 
 
 
 
 
12
13
14
15
0
@@ -1,4 +1,5 @@
0
 class TemplateSweeper < ActionController::Caching::Sweeper
0
+ include Mephisto::SweeperMethods
0
   observe Template
0
 
0
   # only sweep updates, not creations
0
@@ -8,10 +9,6 @@ class TemplateSweeper < ActionController::Caching::Sweeper
0
   end
0
 
0
   def after_save(record)
0
- return if controller.nil?
0
- controller.class.benchmark "Expired all referenced pages" do
0
- CachedPage.find(:all).each { |p| controller.class.expire_page(p.url) }
0
- CachedPage.delete_all
0
- end if @new.nil? && controller
0
+ expire_cached_pages "Expired all referenced pages", *CachedPage.find(:all) if @new.nil? && controller
0
   end
0
 end
0
\ No newline at end of file
...
52
53
54
55
56
 
 
 
 
57
...
52
53
54
 
55
56
57
58
59
60
0
@@ -52,4 +52,7 @@ end
0
 # end
0
 
0
 # Include your application configuration below
0
-require 'mephisto_init'
0
\ No newline at end of file
0
+require 'mephisto_init'
0
+
0
+# turn this on to get detailed cache sweeper logging in production mode
0
+# Mephisto::SweeperMethods.cache_sweeper_tracing = true
0
\ No newline at end of file

Comments

    No one has commented yet.