my $hostname = 'foo.bar.example.com' use Cache::FileCache; my $cache = new Cache::FileCache( { 'namespace' => 'HostInfo', 'default_expires_in' => 600 } ); my $cacheKey = $hostname; my $host_info = $cache->get( $cacheKey ); if ( not defined $host_info ) { $customer = get_host_info_as_hashref( $hostname ); $cache->set( $cacheKey, $host_info, "10 minutes" ); } return $host_info;