From: Michael Andreen Date: Thu, 28 Dec 2006 12:01:05 +0000 (+0000) Subject: cache templates in memory X-Git-Url: https://ruin.nu/git/?a=commitdiff_plain;h=3d83e79b81e65a009360743155f0324293d13e67;p=ndwebbie.git cache templates in memory --- diff --git a/include.pl b/include.pl index 0bf16a8..76c4541 100644 --- a/include.pl +++ b/include.pl @@ -84,7 +84,7 @@ ORDER BY r.tick+c.wave,x,y,z}); , AJAX => $ND::AJAX, JoinName => $target->{joinable} ? 'N' : 'J' , Joinable => $target->{joinable} ? 'FALSE' : 'TRUE'}; } - my $template = HTML::Template->new(filename => "templates/targetlist.tmpl"); + my $template = HTML::Template->new(filename => "templates/targetlist.tmpl", cache => 1); $template->param(Targets => \@targets); return $template->output; } diff --git a/index.pl b/index.pl index abedcdf..ddc22f4 100755 --- a/index.pl +++ b/index.pl @@ -26,6 +26,14 @@ use DBD::Pg qw(:pg_types); use strict; my $cgi = new CGI; +local $ND::DBH; +local $ND::USER; +local $ND::UID; +local $ND::PLANET; +local $ND::TEMPLATE; +local $ND::BODY; +local $ND::TICK; + our $DBH = undef; our $USER = $ENV{'REMOTE_USER'}; my $error; @@ -34,7 +42,7 @@ if ($ENV{'DOCUMENT_ROOT'} =~ m{((\w|/)+)}){ chdir $1; } -our $TEMPLATE = HTML::Template->new(filename => 'templates/skel.tmpl', global_vars => 1); +our $TEMPLATE = HTML::Template->new(filename => 'templates/skel.tmpl', global_vars => 1, cache => 1); for my $file ("db.pl","include.pl"){ unless (my $return = do $file){ @@ -76,10 +84,10 @@ our $AJAX = 1; my $type = 'text/html'; if ($XML){ $type = 'text/xml'; - $ND::TEMPLATE = HTML::Template->new(filename => "templates/xml.tmpl"); - $ND::BODY = HTML::Template->new(filename => "templates/${page}.xml.tmpl"); + $ND::TEMPLATE = HTML::Template->new(filename => "templates/xml.tmpl", cache => 1); + $ND::BODY = HTML::Template->new(filename => "templates/${page}.xml.tmpl", cache => 1); }else{ - $ND::BODY = HTML::Template->new(filename => "templates/${page}.tmpl", global_vars => 1); + $ND::BODY = HTML::Template->new(filename => "templates/${page}.tmpl", global_vars => 1, cache => 1); $ND::BODY->param(PAGE => $page); }