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.
see DISCRIPTION.
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 stat).
stat
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, <fh@laudatio.com>
YAML.
To install YAML::LoadFileCached, copy and paste the appropriate command in to your terminal.
cpanm
cpanm YAML::LoadFileCached
CPAN shell
perl -MCPAN -e shell install YAML::LoadFileCached
For more information on module installation, please visit the detailed CPAN module installation guide.