1ExpireLRU(3) User Contributed Perl Documentation ExpireLRU(3)
2
3
4
6 Memoize - Expiry plug-in for Memoize that adds LRU cache expiration
7
9 use Memoize;
10
11 memoize('slow_function',
12 TIE => [Memoize::ExpireLRU,
13 CACHESIZE => n,
14 ]);
15
16 Note that one need not "use" this module. It will be found by the
17 Memoize module.
18
19 The argument to CACHESIZE must be an integer. Normally, this is all
20 that is needed. Additional options are available:
21
22 TUNECACHESIZE => m,
23 INSTANCE => 'descriptive_name',
24 TIE => '[DB_File, $filename, O_RDWR | O_CREATE, 0666]'
25
27 For the theory of Memoization, please see the Memoize module
28 documentation. This module implements an expiry policy for Memoize that
29 follows LRU semantics, that is, the last n results, where n is
30 specified as the argument to the "CACHESIZE" parameter, will be cached.
31
33 It is often quite difficult to determine what size cache will give
34 optimal results for a given function. To aid in determining this,
35 ExpireLRU includes cache tuning support. Enabling this causes a
36 definite performance hit, but it is often useful before code is
37 released to production.
38
39 To enable cache tuning support, simply specify the optional
40 "TUNECACHESIZE" parameter with a size greater than that of the
41 "CACHESIZE" parameter.
42
43 When the program exits, a set of statistics will be printed to stderr.
44 If multiple routines have been memoized, separate sets of statistics
45 are printed for each routine. The default names are somewhat cryptic:
46 this is the purpose of the "INSTANCE" parameter. The value of this
47 parameter will be used as the identifier within the statistics report.
48
50 Two additional routines are available but not exported.
51 Memoize::ExpireLRU::ShowStats returns a string identical to the
52 statistics report printed to STDERR at the end of the program if test
53 caches have been enabled; Memoize::ExpireLRU::DumpCache takes the
54 instance name of a memoized function as a parameter, and returns a
55 string describing the current state of that instance.
56
58 Brent B. Powers (B2Pi), Powers@B2Pi.com
59
60 Copyright(c) 1999 Brent B. Powers. All rights reserved. This program is
61 free software, you may redistribute it and/or modify it under the same
62 terms as Perl itself.
63
65 Memoize
66
67
68
69perl v5.12.1 2000-04-12 ExpireLRU(3)