YAML::LoadFileCached - A wrapper around YAML::LoadFile with caching capabilities.
use YAML::LoadFileCached; use Data::Dumper; my $data = LoadFileCached('data.yaml'); print Dumper($data);
This module provides a way to gain speed improvements when you have to repeatedly read a file in YAML format (eg. configuration files) under mod_perl or in a long running process, although at the cost of memory expense.
The by default exported function LoadFileCached caches the results from YAML::LoadFile and simply returns them if called repeatedly.
If the requested file has been changed since the last request, LoadFileCached will reread it.
this by default not exported function returns statistics for the cache used by LoadFileCached. If given filepath it returns a Hashref with the keys:
the last modify time in seconds since the epoch (as retourned by
number of calls to YAML::LoadFile.
number of cache-served requests.
If called with no argument, CacheStatistics returns a Hash of Hashrefs with filepath as key in the first level.
Florian Helmberger, <email@example.com>
$Id: LoadFileCached.pm,v 1.3 2003/02/03 12:10:01 florian Exp $
Copyright (c) 2002 - 2003, Florian Helmberger. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the terms of the Perl Artistic License (see http://www.perl.com/perl/misc/Artistic.html).