public
Fork of wycats/merb-more
Description: Merb More: The Full Stack. Take what you need; leave what you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/fightinjoe/merb-more.git
Search Repo:
Minor documentation examples added.
Added flag to turn off page caching when caching is disabled.
NOTE: disabled caching won't cache new page_cache requests, but
will serve stale ones.
NOTE: there are no tests for this, primarily because most of the
specs fail when run against a dummy store.
Aaron Wheeler (author)
Fri Mar 21 17:36:13 -0700 2008
commit  feaed59155bc9d762176914802284a46a0cf50db
tree    36dae16853ab23c4b4dde8ddbc006fcc0af768b6
parent  cd8d13709833abf4e68b2ca855a9f2d616263f74
...
64
65
66
67
 
 
 
 
 
68
 
 
69
70
71
...
75
76
77
 
78
79
80
...
109
110
111
 
 
 
 
 
 
112
113
114
...
64
65
66
 
67
68
69
70
71
72
73
74
75
76
77
...
81
82
83
84
85
86
87
...
116
117
118
119
120
121
122
123
124
125
126
127
0
@@ -64,8 +64,14 @@ module Merb::Cache::ControllerInstanceMethods
0
   # ==== Parameter
0
   # options<String,Hash>:: The options that will be passed to #expire_key_for
0
   #
0
- # ==== Examples
0
+ # ==== Examples (See Merb::Cache#expire_key_for for more options)
0
+ # # will expire path/to/page/cache/news/show/1.html
0
+ # expire_page(:key => url(:news,News.find(1)))
0
+ #
0
+ # # will expire path/to/page/cache/news/show.html
0
   # expire_page(:action => 'show', :controller => 'news')
0
+ #
0
+ # # will expire path/to/page/cache/news/show*
0
   # expire_page(:action => 'show', :match => true)
0
   def expire_page(options)
0
     config_dir = Merb::Controller._cache.config[:cache_html_directory]
0
@@ -75,6 +81,7 @@ module Merb::Cache::ControllerInstanceMethods
0
       else
0
         files = config_dir / "#{key}.html"
0
       end
0
+ Merb.logger.info("cache: expiring pages matching #{files}")
0
       FileUtils.rm_rf(files)
0
     end
0
     true
0
@@ -109,6 +116,12 @@ module Merb::Cache::ControllerInstanceMethods
0
     path = "index" if path.empty?
0
     cache_file = Merb::Controller._cache.config[:cache_html_directory] / "#{path}.html"
0
     if data
0
+ # If caching is disabled, don't save the cached page, but do return
0
+ # the page if previously cached.
0
+ if Merb::Controller._cache.config[:disable_page_caching]
0
+ Merb.logger.info("cache: deactivated (#{path})")
0
+ return true
0
+ end
0
       cache_directory = File.dirname(cache_file)
0
       FileUtils.mkdir_p(cache_directory)
0
       _expire_in = pages[action][0]
...
41
42
43
 
44
45
46
...
41
42
43
44
45
46
47
0
@@ -41,6 +41,7 @@ class Merb::Cache
0
     @config = DEFAULT_CONFIG.merge(Merb::Plugins.config[:merb_cache] || {})
0
     if @config[:disable] == true || Merb.environment == @config[:disable]
0
       config[:store] = "dummy"
0
+ config[:disable_page_caching] = true
0
     end
0
     @config[:cache_html_directory] ||= Merb.dir_for(:public) / "cache"
0
     require "merb-cache/cache-store/#{@config[:store]}"

Comments

    No one has commented yet.