IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9499


Ignore:
Timestamp:
Oct 11, 2006, 4:35:49 PM (20 years ago)
Author:
jhoblitt
Message:

move all caching into cache_run()

File:
1 edited

Legend:

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

    r9493 r9499  
    8080
    8181my $c = Cache::File->new(
    82     cache_root => File::Spec->catdir($ENV{'HOME'}, '.', basename($0)),
     82    cache_root => File::Spec->catdir($ENV{'HOME'}, '.pxtools', basename($0)),
    8383    default_expires => '7200 sec',
    8484);
     
    9292    my $command = "$ppStats $uri -recipe PPSTATS " . RECIPE; # Command to run ppStats
    9393
    94     ### cache hook
    95     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf );
    96     my $cmd_output = $c->get($command) if $cache;
    97     if (defined $cmd_output) {
    98         ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf )
    99             = @{thaw $cmd_output};
    100     } else {
    101         my @output = run(command => $command, verbose => 1);
    102         $c->set($command, freeze \@output) if $cache;
    103         ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf )
    104             = @output;
    105     }
    106     ### end cache hook
    107 
     94    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     95        cache_run(command => $command, verbose => 1);
    10896    die "Unable to perform ppStats on exposure id $exp_tag: $error_code\n"
    10997        if not $success;
     
    146134}
    147135
     136sub cache_run
     137{
     138    my %p = @_;
     139
     140    my $cmd_output = $c->get($p{command}) if $cache;
     141    if (defined $cmd_output) {
     142        return @{thaw $cmd_output};
     143    } else {
     144        my @output = run(%p);
     145        $c->set($p{command}, freeze \@output) if $cache;
     146        return @output;
     147    }
     148}
     149
    148150# Pau.
    149151
Note: See TracChangeset for help on using the changeset viewer.