In the examples below, $cache is created in the base class with:
my $cache = new Cache::FileCache( { 'namespace' => 'mynamespace',
'default_expires_in' => '1 hour' } );
In cgiapp_prerun, check for cache and switch mode if found
sub cgiapp_prerun {
my ($self, $rm) = @_;
my $cache_key = ref($self) . "-$rm";
$self->param(cache_key => $cache_key); my $output = $cache->get($cache_key);
if ($output) {
$self->param(cached_output => \$output);
$self->prerun_mode('output_cached');
}
}---
In cgiapp_postrun, cache output using the cache_key set above
sub cgiapp_postrun {
my $self = shift;
my $output_ref = shift;
my $rm = $self->get_current_runmode();
$cache->set($self->param('cache_key'), $$output_ref);
}---
output_cached is in the base class too -
sub output_cached {
my $self = shift;
warn "output_cached called";
return $self->param('cached_output');
}-- Barry Hoggard Tristan Media LLC w: www.tristanmedia.com yahoo/aim: hoggardb
--------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[email protected]/ http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
