package Stonehenge::Template::Plugin::CacheFileCache;
use Cache::FileCache;
use base qw(Template::Plugin);
sub new {
my $class = shift;
my $context = shift;
Cache::FileCache->new(@_);
}
1;
to my webserver's mod_perl search path, and
TT2PluginBase Stonehenge::Template::Plugin
to my config file, and now I can say:
USE mycache = CacheFileCache({
namespace => 'stonehenge-nav_stacked_bars',
default_expires_in => 1800,
auto_purge_interval => 1800,
});
mykey = [class, instance, global.navbardata.modtime];
mykey = mykey.join(":");
result = mycache.get(mykey);
UNLESS result;
result = BLOCK;
[[ stuff to compute result deleted ]]
END;
mycache.set(mykey, result);
FILTER stderr; "cache miss on "; mykey; "\n"; END;
END;
result;
to my navbar generation template, and I've just cached the creation of my navbars (function of class, instance, and the timestamp on the navbar data).
TT2 rocks. Cache::Cache rocks. 'nuff said.
so the second codeblock goes in the template? (Score:1)
Is there an article coming on using TT and caching and filters? go on you know you want to :)
@JAPH = qw(Hacker Perl Another Just);
print reverse @JAPH;
Re:so the second codeblock goes in the template? (Score:2)