# Code from the perldoc use Memoize; use Memoize::Expire; use DB_File; # Set up persistence tie my %disk_cache => 'DB_File', $filename, O_CREAT|O_RDWR, 0666]; # Set up expiration policy, supplying persistent hash as a target tie my %cache => 'Memoize::Expire', LIFETIME => $lifetime, # In seconds NUM_USES => $n_uses, HASH => \%disk_cache; # Set up memoization, supplying expiring persistent hash for cache memoize 'function', SCALAR_CACHE => [ HASH => \%cache ]; #### if(exists($args{HASH})) { $args{C} = $args{HASH}; } else { $args{C} = \%cache; }