Re: HTML::Template bug report: Problems using cache

Jozef Kosoru <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.html-template
Message-ID <[email protected]>
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


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.