6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/cache_server.rb', line 6
def process(request, response)
Mongrel::PageCacheHandler::Utils.do_work(request, response) do
case (app_config.page_cache_storage || "disk")
when "cachetastic"
file_path = Mongrel::PageCacheHandler::Utils.build_cachetastic_key(request)
f = Cachetastic::Caches::PageCache.get(file_path)
if f
puts "We found: #{file_path} in the cache, let's render it"
response.start(200, true) do |head, out|
out.write(f)
end
end
when "disk"
file_path = Mongrel::PageCacheHandler::Utils.build_full_file_path(request)
if File.exists?(file_path)
puts "We found: #{file_path} on the disk, let's render it"
response.start(200, true) do |head, out|
out.write(File.open(file_path).read)
end
end
end
end
end
|