Hi, Radiant uses YAML for caching pages, but I think Marshal is better. I recommend Marshal because YAML has a problem of handling multi-byte characters and YAML is slower than Marshal. I attached the patch for using Marshal, this works fine in my environment.
1. multi-byte characters problem I experienced a problem that pages including japanese characters were broken. This is the same as "[Radiant] Cache problems" by bodhi. (see http://www.mail-archive.com/[email protected]/msg00660.html) When I try Marshal for caching, pages including japanese characters are fine. I think YAML has a problem of handling multi-byte characters. 2. YAML is slower than Marshal I compared YAML and Marshal performance by runing "test.rb"(attached this mail), the result is YAML(dump):8.319402 Marshal(dump):0.323576 YAML(load):1.252383 Marshal(load):0.374623 I think caching by YAML has no advantage(excuding debug?). Maybe it would be better to replace YAML by Marshal or use Marshal in production environment. ---- Keita Yamguchi
--- app/models/response_cache.rb.orig 2006-09-29 13:22:11.000000000 +0900
+++ app/models/response_cache.rb 2006-09-29 14:41:17.000000000 +0900
@@ -94,7 +94,7 @@
# Reads a cached response from disk and updates a response object.
def read_response(path, response)
if content = read_page(path)
- updates = YAML::load(content)
+ updates = Marshal.load(content)
response.headers.merge!(updates['headers'] || {})
response.body = updates['body']
end
@@ -103,10 +103,10 @@
# Writes a response to disk.
def write_response(path, response)
- content = {
+ content = Marshal.dump({
'headers' => response.headers,
'body' => response.body
- }.to_yaml
+ })
cache_page(content, path)
end
end
test.rb
Description: application/ruby
_______________________________________________ Radiant mailing list Post: [email protected] Search: http://radiantcms.org/mailing-list/search/ Site: http://lists.radiantcms.org/mailman/listinfo/radiant
