Index: trunk/ippScripts/scripts/phase0_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/phase0_imfile.pl	(revision 9446)
+++ trunk/ippScripts/scripts/phase0_imfile.pl	(revision 9468)
@@ -11,4 +11,5 @@
 use PS::IPP::Metadata::Stats;
 use Data::Dumper;
+use Cache::File;
 
 use PS::IPP::Config;
@@ -19,8 +20,9 @@
 use Pod::Usage qw( pod2usage );
 
-my ($exp_tag, $class_id, $uri, $no_update);
+my ($cache, $exp_tag, $class_id, $uri, $no_update);
 
 GetOptions(
-    'exp_tag|e=s'    => \$exp_tag,
+    'caches'        => \$cache,
+    'exp_tag|e=s'   => \$exp_tag,
     'class_id|i=s'  => \$class_id,
     'uri|u=s'       => \$uri,
@@ -74,4 +76,11 @@
 die "Can't find required tools.\n" if $missing_tools;
 
+# setup cache interface
+
+my $c = Cache::File->new(
+    cache_root => File::Spec->catdir($ENV{'HOME'}, '.pxcache'),
+    default_expires => '7200 sec',
+);
+
 # Resolve the input URI
 $uri = File::Spec->rel2abs( $uri, $ipprc->workdir() );
@@ -81,7 +90,21 @@
 {
     my $command = "$ppStats $uri -recipe PPSTATS " . RECIPE; # Command to run ppStats
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => 1);
-    die "Unable to perform ppStats on exposure id $exp_tag: $error_code\n" if not $success;
+
+    ### cache hook
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf );
+    my $cmd_output = $c->get($command) if $cache;
+    if (defined $cmd_output) {
+        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf )
+            = @{$cmd_output};
+    } else {
+        my @output = run(command => $command, verbose => 1);
+        $c->set($command, \@output) if $cache;
+        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf )
+            = @output;
+    }
+    ### end cache hook
+
+    die "Unable to perform ppStats on exposure id $exp_tag: $error_code\n"
+        if not $success;
     
     # Parse the output
