# init cache object at the begining of the program my $CACHE = new Cache::FileCache( ); ..... ..... #### Cut, subroutine from module foreach my $tid (@completed){ $results{$tid} = $CACHE->get($tid); unless(defined $results{$tid}) { $results{$tid} = $self->Complex_Crap($tid); # data will expire in cache in 10 minutes $CACHE->set($tid => $results{$tid}, "10 minutes"); } } $self->Results(\%results); return($self); }