NAME
Beam::Make::Cache - Store information about recipes performed
VERSION
version 0.002
SYNOPSIS
my $cache = Beam::Make::Cache->new;
# Update the cache and track what the content should be
$cache->set( 'recipe', 'content hash' );
# Set the last modified time to a specific time by passing
# a Time::Piece object
$cache->set( 'recipe', 'content hash', $timestamp );
# Get a Time::Piece object if the content hashes match
# Otherwise returns 0
my $time = $cache->last_modified( 'recipe', 'content hash' );
DESCRIPTION
This class provides an API to access timestamps and content hashes to validate recipes and determine which recipes are out-of-date and should be re-run.
Limitations
The cache file cannot be accessed by more than one process. This limitation may be fixed in the future. Other cache modules that use distributed databases may also be created in the future.
ATTRIBUTES
file
The path to a file to use for the cache. Defaults to .Beamfile.cache
in the current directory.
METHODS
set
$cache->set( $name, $hash, $time );
# Update modified time to now
$cache->set( $name, $hash );
Set an entry in the cache. $name
is the recipe name. $hash
is an identifier for the content (usually a base64 SHA-1 hash from Digest::SHA). $time
is a Time::Piece object to save as the last modified time. If $time
is not provided, defaults to now.
last_modified
my $time = $cache->last_modified( $name, $hash );
Get the last modified timestamp (as a Time::Piece object) for the given recipe $name
. If the $hash
does not match what was given to "set", or if the recipe has never been made, returns 0
.
SEE ALSO
AUTHOR
Doug Bell <preaction@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2020 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.