[Templates] Storing compiled templates to memcached?
Peter Hartzler
pete@hartzler.net
Sun, 9 Sep 2007 10:52:32 -0400
Greetings!
I am investigating the possibility of using memcached or similar to
cache compiled templates, to eliminate the redundancy where each apache
child/mod_perl instance keeps it's own set. We're using Debian etch; TT
2.14. Browsing the list archives suggests that anyone doing this is
keeping quiet about it. If I've missed something, do let me know.
Firstly, is this a sane idea? Looking at the compiled temlates as
written to disk, it seems like it should be possible to save off a copy
of that to memcached, then intercept subsequent reads with a memcached
poll. Setting CACHE_SIZE => 0 would then disable the per-apache-child
cache.
Going FURTHER out on this limb, it seems like overriding
Template::Document::write_perl_file() for saves, and
Template::Provider::_load_compiled() for reads might work.
BUT, I'm not clear on whether I really want to save off the perl file,
or the result of eval $file_data. I'm guessing perl file, since there's
no guarantee that different apache children will have the same
Template::Context state.
Anyhow, thanks for reading this far, and if you have any helpful
pointers, please let me know! Meanwhile, I'll continue to trace through
and try to understand the right way to do this.
Kindest Regards,
Pete.