SYNOPSIS

    use Memoize;

    memoize('slow_function',
            TIE => [Memoize::ExpireLRU,
                    CACHESIZE => n,
                   ]);

Note that one need not \*(C`use\*(C' this module. It will be found by the Memoize module.

The argument to \s-1CACHESIZE\s0 must be an integer. Normally, this is all that is needed. Additional options are available:

TUNECACHESIZE => m, INSTANCE => 'descriptive_name', TIE => '[DB_File, $filename, O_RDWR | O_CREATE, 0666]'

DESCRIPTION

For the theory of Memoization, please see the Memoize module documentation. This module implements an expiry policy for Memoize that follows \s-1LRU\s0 semantics, that is, the last n results, where n is specified as the argument to the \*(C`CACHESIZE\*(C' parameter, will be cached.

PERFORMANCE TUNING

It is often quite difficult to determine what size cache will give optimal results for a given function. To aid in determining this, ExpireLRU includes cache tuning support. Enabling this causes a definite performance hit, but it is often useful before code is released to production.

To enable cache tuning support, simply specify the optional \*(C`TUNECACHESIZE\*(C' parameter with a size greater than that of the \*(C`CACHESIZE\*(C' parameter.

When the program exits, a set of statistics will be printed to stderr. If multiple routines have been memoized, separate sets of statistics are printed for each routine. The default names are somewhat cryptic: this is the purpose of the \*(C`INSTANCE\*(C' parameter. The value of this parameter will be used as the identifier within the statistics report.

DIAGNOSTIC METHODS

Two additional routines are available but not exported. Memoize::ExpireLRU::ShowStats returns a string identical to the statistics report printed to \s-1STDERR\s0 at the end of the program if test caches have been enabled; Memoize::ExpireLRU::DumpCache takes the instance name of a memoized function as a parameter, and returns a string describing the current state of that instance.

AUTHOR

Brent B. Powers (B2Pi), [email protected]

Copyright(c) 1999 Brent B. Powers. All rights reserved. This program is free software, you may redistribute it and/or modify it under the same terms as Perl itself.

RELATED TO Memoize::ExpireLRU…

Memoize