in reply to Re^2: Cache commands output
in thread Cache commands output

You can certainly cache the output of some command with Cache::FileCache.

sub qx_cache { my $cmd = shift; my $cache = Cache::FileCache->new({ namespace => $0 }); die 'no cache' if ! $cache; my $out = $cache->get( $cmd ); if ( ! defined $out ) { $out = qx{ $cmd }; $cache->set( $cmd, $out ); } return $out; }

You can set a timeout value when you call set(). Any get() on a key that's expired will come back undef.

Replies are listed 'Best First'.
Re^4: Cache commands output
by Anonymous Monk on Oct 22, 2008 at 13:24 UTC
    Thanks, everyone!

    I will try Cache::FileCache. :)