[htmltmpl] Re: HTML::Template bug report: Problems using cache
Brought to you by:
samtregar
From: Jozef K. <zy...@ui...> - 2005-11-30 21:25:40
|
Hello, thanks for the answer. On Tue, Nov 29, 2005 at 19:01:12 -0500, Sam Tregar wrote: > > my $rTmpl1 = HTML::Template->new(filename => $htmlTemplate, cache => 1); > > my $rTmpl2 = HTML::Template->new(filename => $htmlTemplate, cache => 1); > > Ok, that won't work. The cache is going to hand you back two > references to the same object. Try this instead: > > use Storable qw(dclone); > my $rTmpl1 = HTML::Template->new(filename => $htmlTemplate, cache => 1); > my $rTmpl2 = dclone($rTmpl2); > > Or, possibly faster: > > use Clone qw(clone); > my $rTmpl1 = HTML::Template->new(filename => $htmlTemplate, cache => 1); > my $rTmpl2 = clone($rTmpl2); Yes, great! That works. But this was simple and rather contrived example. In practice it's impossible (or at least impractical) to make as many clones of the same template object as needed before thay are used. I would therefore like to introduce a new cache option "cloned_cache" which will use cached data only as a template for making clones. I'll try to implement it myself but as I've looked to sources - it won't be that easy :) But I think this strategy must already be used for the "shared_cache", isn't it? Because in that case many processes may use the cached data in the same time. Regards, Jozef -- jozef kosoru http://zyzstar.kosoru.com |