The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Text::Forge::MemCache - Memory Cache for Text::Forge Templates

SYNOPSIS

 use Text::Forge;
 my $forge = new Text::Forge;
 $forge->cache_module('Text::Forge::MemCache');

DESCRIPTION

The Text::Forge::MemCache class allows templates to be cached in memory for faster execution. Running previously cached templates requires no disk access, and completely by-passes the parsing and compilation phases. This is the default cache module for Text::Forge and its subclasses.

The class implements a Least Recently Used (LRU) replacement algorithm to limit memory consumption. The two package globals, $Max_Templates and $Min_Templates control the upper and lower boundaries. If the number of cached templates exceeds $Max_Templates, then templates are evicted from the cache on an LRU basis until no more than $Min_Templates remain.

Setting $Max_Templates to zero disables the replacement algorithm altogether; templates are always cached and are never evicted. This is the default value, since the replacement algorithm is somewhat expensive.

If $Max_Templates is set to a positive value, $Min_Templates should be set appropriately. Setting $Min_Templates to zero causes the entire cache to be flushed once $Max_Templates has been exceeded, and is not recommended.

Note that evicting cached templates will not release the memory back to the kernel (i.e. the process size will not decrease). Instead, the memory will be released to the perl interpreter, making it available for other purposes within your application.

Under mod_perl, this module adds an entry for Apache::Status, which allows you to view the state of the cache. All cached templates are displayed, along with their relative ages in the replacement algorithm. If the replacement algorithm has been disabled, all of the ages will remain fixed at zero. You must load the Apache::Status module prior to Text::Forge::MemCache in order to have the status entry appear.

AUTHOR

Copyright 1998-1999, Maurice Aubrey <maurice@hevanet.com>. All rights reserved.

This module is free software; you may redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Text::Forge::NoCache, Text::Forge, Apache::Status