IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9476


Ignore:
Timestamp:
Oct 10, 2006, 2:12:59 PM (20 years ago)
Author:
jhoblitt
Message:

first cut cache support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/cache/ippScripts/scripts/phase0_imfile.pl

    r9446 r9476  
    1111use PS::IPP::Metadata::Stats;
    1212use Data::Dumper;
     13use Cache::File;
    1314
    1415use PS::IPP::Config;
     
    1920use Pod::Usage qw( pod2usage );
    2021
    21 my ($exp_tag, $class_id, $uri, $no_update);
     22my ($cache, $exp_tag, $class_id, $uri, $no_update);
    2223
    2324GetOptions(
    24     'exp_tag|e=s'    => \$exp_tag,
     25    'caches'        => \$cache,
     26    'exp_tag|e=s'   => \$exp_tag,
    2527    'class_id|i=s'  => \$class_id,
    2628    'uri|u=s'       => \$uri,
     
    7476die "Can't find required tools.\n" if $missing_tools;
    7577
     78# setup cache interface
     79
     80my $c = Cache::File->new(
     81    cache_root => File::Spec->catdir($ENV{'HOME'}, '.pxcache'),
     82    default_expires => '7200 sec',
     83);
     84
    7685# Resolve the input URI
    7786$uri = File::Spec->rel2abs( $uri, $ipprc->workdir() );
     
    8190{
    8291    my $command = "$ppStats $uri -recipe PPSTATS " . RECIPE; # Command to run ppStats
    83     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    84         run(command => $command, verbose => 1);
    85     die "Unable to perform ppStats on exposure id $exp_tag: $error_code\n" if not $success;
     92
     93    ### cache hook
     94    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf );
     95    my $cmd_output = $c->get($command) if $cache;
     96    if (defined $cmd_output) {
     97        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf )
     98            = @{$cmd_output};
     99    } else {
     100        my @output = run(command => $command, verbose => 1);
     101        $c->set($command, \@output) if $cache;
     102        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf )
     103            = @output;
     104    }
     105    ### end cache hook
     106
     107    die "Unable to perform ppStats on exposure id $exp_tag: $error_code\n"
     108        if not $success;
    86109   
    87110    # Parse the output
Note: See TracChangeset for help on using the changeset viewer.