- PRIVATE METHODS
- PUBLIC METHODS
XML::Template::Cache::File - Document caching to files module.
use XML::Template::Cache::File; my $cache = XML::Template::Cache::File->new (%config) || die XML::Template::Cache::File->error; my $document = XML::Template::Document->new (); $cache->put ($docname, $document); $document = $cache->get ($docname);
This modules provides XML template caching to files. The files store the code generated from the template. When the template is requested, the code from the file can be quickly loaded and evaluated.
If file caching is turned on, in the initialization of XML::Template::Process, a file cache object is placed in the load and put chain of responsiblity lists after the normal cache object. Hence, every load and put operation on a document will result in the file cache being queried right after the normal cache.
A constructor method
new is provided by XML::Template::Base. A list of named configuration parameters may be passed to the constructor. The constructor returns a reference to a new cache object or undef if an error occurred. If undef is returned, you can use the method
error to retrieve the error. For instance:
my $cache = XML::Template::Cache::File->new (%config) || die XML::Template::Cache->error;
The following named configuration parameters are supported by this module:
The directory to store parsed XML templated in. This value will override the default value
$CACHE_DIRin XML::Template::Config. The default file cache directory is
This method is the internal initialization function called from XML::Template::Base when a new cache object is created.
my $document = $cache->load ($docname);
load method, returns a document stored in the cache named by the parameter. If no document is found, undef is returned.
my $document = XML::Template::Document->new (Code => $code); $cache->put ($docname, $document);
put method stores a document in the cache. If the cache is full, the oldest accessed document is replaced. The first parameter is the name of the document. The second parameter is a blessed reference to the XML::Template::Document object to store.
Jonathan Waxman <firstname.lastname@example.org>
Copyright (c) 2002-2003 Jonathan A. Waxman All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.