Memoize::ExpireLRU(3)
π NAME π
okay so this is the Memoize::ExpireLRU(3) page from the User Contributed Perl Documentation, bestie β and itβs literally the expiry plug-in for Memoize that adds LRU cache expiration. slay. π
β¨ SYNOPSIS β¨
use Memoize;
memoize('slow_function',
TIE => [Memoize::ExpireLRU,
CACHESIZE => n,
]);
okay important vibe check: you do not need to use this module. Memoize will find it for you. no cap. π«Ά
The argument to CACHESIZE 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]'
TUNECACHESIZE => mβ the optional cache-tuning size, bestie. πINSTANCE => 'descriptive_name'β gives your memoized routine a cute descriptive name for the stats report. πTIE => '[DB_File, $filename, O_RDWR | O_CREATE, 0666]'β the extraTIEform shown here, exactly as written. π₯
π¦ DESCRIPTION π¦
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 CACHESIZE parameter, will be cached. periodt. π
πΈ 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.
fair warning, bestie: turning this on causes a definite performance hit π but itβs often useful before code goes to production. lowkey worth it for the data. π
To enable cache tuning support, simply specify the optional TUNECACHESIZE parameter with a size greater than that of the CACHESIZE 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 INSTANCE 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 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. iykyk. π
π SEE ALSO π
Memoize
π§ REPOSITORY π§
<https://github.com/neilb/Memoize-ExpireLRU>
π AUTHOR π
Brent B. Powers (B2Pi), Powers@B2Pi.com
π COPYRIGHT AND LICENSE π
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.
π«Ά cute sign-off: this page is from perl v5.42.0, dated 2016-07-08, and its manual name is Memoize::ExpireLRU(3) β bye bestie! π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Memoize-ExpireLRU 0.56-bp160.1.11 Β· Artistic-1.0 or GPL-1.0+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms