tylerkovacs-extended_fragment_cache 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +1 -1
- data/lib/extended_fragment_cache.rb +9 -11
- metadata +2 -2
data/VERSION.yml
CHANGED
|
@@ -67,7 +67,7 @@ module ActionController
|
|
|
67
67
|
content = ApplicationController.local_fragment_cache[key]
|
|
68
68
|
ApplicationController.benchmark "Fragment read: #{key}" do
|
|
69
69
|
if content.nil?
|
|
70
|
-
content =
|
|
70
|
+
content = ActionController::Base.cache_store.read(key, options)
|
|
71
71
|
ApplicationController.local_fragment_cache[key] = content
|
|
72
72
|
end
|
|
73
73
|
end
|
|
@@ -90,7 +90,7 @@ module ActionController
|
|
|
90
90
|
key = self.fragment_cache_key(name)
|
|
91
91
|
ApplicationController.benchmark "Cached fragment: #{key}" do
|
|
92
92
|
ApplicationController.local_fragment_cache[key] = content
|
|
93
|
-
|
|
93
|
+
ActionController::Base.cache_store.write(key, content, options)
|
|
94
94
|
end
|
|
95
95
|
content
|
|
96
96
|
rescue NameError => err
|
|
@@ -111,11 +111,11 @@ module ActionController
|
|
|
111
111
|
|
|
112
112
|
if key.is_a?(Regexp)
|
|
113
113
|
ApplicationController.benchmark "Expired fragments matching: #{key.source}" do
|
|
114
|
-
|
|
114
|
+
ActionController::Base.cache_store.delete_matched(key, options)
|
|
115
115
|
end
|
|
116
116
|
else
|
|
117
117
|
ApplicationController.benchmark "Expired fragment: #{key}" do
|
|
118
|
-
|
|
118
|
+
ActionController::Base.cache_store.delete(key, options)
|
|
119
119
|
end
|
|
120
120
|
end
|
|
121
121
|
rescue NameError => err
|
|
@@ -174,12 +174,12 @@ module ActionView
|
|
|
174
174
|
module Helpers
|
|
175
175
|
# See ActionController::Caching::Fragments for usage instructions.
|
|
176
176
|
module CacheHelper
|
|
177
|
-
def cache(
|
|
178
|
-
if
|
|
177
|
+
def cache(key, options={}, interpolation={}, &block)
|
|
178
|
+
if key.blank? or (options.has_key?(:if) and !options[:if])
|
|
179
179
|
yield
|
|
180
180
|
else
|
|
181
181
|
begin
|
|
182
|
-
content = @controller.
|
|
182
|
+
content = @controller.fragment_for(output_buffer, key, options, interpolation, &block) || ""
|
|
183
183
|
rescue MemCache::MemCacheError => err
|
|
184
184
|
content = ""
|
|
185
185
|
end
|
|
@@ -196,16 +196,14 @@ module ActionController
|
|
|
196
196
|
module Caching
|
|
197
197
|
module Fragments
|
|
198
198
|
# Called by CacheHelper#cache
|
|
199
|
-
def
|
|
200
|
-
unless perform_caching then
|
|
199
|
+
def fragment_for(buffer, name={}, options=nil, interpolation={}, &block)
|
|
200
|
+
unless (perform_caching && cache_store) then
|
|
201
201
|
content = block.call
|
|
202
202
|
interpolation.keys.each{|k|content.sub!(k.to_s,interpolation[k].to_s)}
|
|
203
203
|
content
|
|
204
204
|
return
|
|
205
205
|
end
|
|
206
206
|
|
|
207
|
-
buffer = eval("_erbout", block.binding)
|
|
208
|
-
|
|
209
207
|
if cache = read_fragment(name, options)
|
|
210
208
|
buffer.concat(cache)
|
|
211
209
|
else
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tylerkovacs-extended_fragment_cache
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- tylerkovacs
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-02-11 00:00:00 -08:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|