Cache::AgainstFile

Cache data structures parsed from files, watching for updates to the file
Download

Cache::AgainstFile Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • BBC
  • Publisher web site:
  • http://www.bbc.co.uk

Cache::AgainstFile Tags


Cache::AgainstFile Description

Cache data structures parsed from files, watching for updates to the file Cache::AgainstFile is a Perl module that caches a data structure against a filename, statting the file to determine whether it has changed and needs to be re-parsed. You supply a routine to generate the data structure given the filename.This module is recommended for files which change infrequently but are read often, especially if they are expensive to parse. Example uses include caching precompiled templates, pre-parsed XML or data files on webservers.This approach has the advantage over lazy caching (where cache items are not validated for a period of time) that multiple processes (e.g. modperl daemons) holding a cache will all update at the same time so you will not get inconsistent results if you request data from different processes.The module itself is simply a factory for various backend modules (each exposing the same API). The distribution includes backends for in-memory caching or file caching using Storable, plus an adaptor to use any modules offering the Cache or Cache::Cache interfaces as the cache implementation.Data structures are automatically serialised/deserialised by the backend modules if they are being persisted somewhere other than in memory (e.g. on the filesystem).SYNOPSIS use Cache::AgainstFile; my $cache = new Cache::AgainstFile(&loader, \%options); $cache->get($filename); $cache->purge(); sub loader { my $filename = shift; my $data_structure = do_really_expensive_parsing($filename); return $data_structure; } Requirements: · Perl


Cache::AgainstFile Related Software