06 Jul 2016 23:05:22 UTC
- Distribution: Memoize-ExpireLRU
- Module version: 0.56
- Source (raw)
- Browse (raw)
- How to Contribute
- Repository (git clone)
- Issues (2)
- Testers (6905 / 0 / 0)
- KwaliteeBus factor: 1
- 71.43% Coverage
- License: perl_5
- Perl: v5.6.0
- Activity24 month
- Download (13.42KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionNEILB Neil Bowersand 1 contributors
- Brent B. Powers
- PERFORMANCE TUNING
- DIAGNOSTIC METHODS
- SEE ALSO
- COPYRIGHT AND LICENSE
Memoize::ExpireLRU - Expiry plug-in for Memoize that adds LRU cache expiration
use Memoize; memoize('slow_function', TIE => [Memoize::ExpireLRU, CACHESIZE => n, ]);
Note that one need not
usethis module. It will be found by the Memoize module.
The argument to
CACHESIZEmust 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]'
For the theory of Memoization, please see the Memoize module documentation. This module implements an expiry policy for Memoize that follows LRU semantics, that is, the last n results, where n is specified as the argument to the
CACHESIZEparameter, will be cached.
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
TUNECACHESIZEparameter with a size greater than that of the
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
INSTANCEparameter. The value of this parameter will be used as the identifier within the statistics report.
Two additional routines are available but not exported. Memoize::ExpireLRU::ShowStats returns a string identical to the statistics report printed to STDERR 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.
Brent B. Powers (B2Pi), Powers@B2Pi.com
This software is copyright (c) 1999 by Brent B. Powers.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install Memoize::ExpireLRU, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Memoize::ExpireLRU
For more information on module installation, please visit the detailed CPAN module installation guide.