The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

YAML::LoadFileCached - A wrapper around YAML::LoadFile with caching capabilities.

SYNOPSIS

  use YAML::LoadFileCached;
  use Data::Dumper;

  my $data = LoadFileCached('data.yaml');

  print Dumper($data);

DESCRIPTION

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.

FUNCTIONS

LoadFileCached (filepath)

see DISCRIPTION.

CacheStatistics ([filepath])

this by default not exported function returns statistics for the cache used by LoadFileCached. If given filepath it returns a Hashref with the keys:

lastchanged

the last modify time in seconds since the epoch (as retourned by stat).

read

number of calls to YAML::LoadFile.

cached

number of cache-served requests.

If called with no argument, CacheStatistics returns a Hash of Hashrefs with filepath as key in the first level.

AUTHOR

Florian Helmberger, <fh@laudatio.com>

SEE ALSO

YAML.