[Templates] Caching of templates passed as file handles
Paul Seamons
mail@seamons.com
Mon, 10 Sep 2007 13:30:37 -0600
On Monday 10 September 2007, Bill Moseley wrote:
> This talk of caching reminded me of something.
>
> IIRC, currently any template passed as a scalar reference or file
> handle is not cached -- there's no associated template name to use as
> the key to the cache.
>
> Seems like there should be a way to specify a key to use for caching
> in this case. Perhaps an addition to the %options param to process() in
> TT2. Not sure about TT3.
Template::Alloy will cache the contents. Internally the contents of the
filehandle are read to a scalarref, which is then passed along. Any
scalarref passed in will be cached based upon the md5 of the string. This
behavior can be disabled, but in all test cases so far, it takes much less
effort to md5 the string than to generate the compiled document (of course
there is a hit if you are single pass, single use, with no external cache -
but if you are doing that then you can set CACHE_STR_REFS => 0).
There has been a little discussion about this previously. I'm hoping that TT3
is still planning this.
Paul