NAME
Petal::Cache::Memory - Caches generated subroutines in memory.
SYNOPSIS
use Petal::Cache::Memory;
my $coderef = Petal::Cache::Memory->get ('foo.html');
unless (defined $coderef)
{
$coderef = complicated_long_compute_thing();
Petal::Cache::Memory->set ($coderef);
}
DESCRIPTION
A simple cache module to avoid re-compiling the Perl
code from the Perl data at each request
METHODS
All the methods are static methods.
$class->get ($file);
Returns the cached subroutine if its last modification time is more recent than the last modification time of the template, returns undef otherwise
$class->set ($file, $code);
Sets the cached code for $file.
$class->is_ok ($file);
Returns TRUE if the cache is still fresh, FALSE otherwise.
$class->cached_mtime ($file);
Returns the last modification date of the cached data for $file
$class->current_mtime ($file);
Returns the last modification date for $file
$class->compute_key ($file);
Computes a cache 'key' for $file, which should be unique. (Well, currently an MD5 checksum is used, which is not *exactly* unique but which should be good enough)
AUTHOR
Jean-Michel Hiver <jhiver@mkdoc.com>
This module is redistributed under the same license as Perl itself.