™.. Tie::Memoize - Online Linux Manual PageSection : 3pm
Updated : 2009-02-12
Source : perl v5.10.1
Note : Perl Programmers Reference Guide
NAMETie::Memoize − add data to hash when needed
SYNOPSIS require Tie::Memoize;
tie %hash, 'Tie::Memoize',
\&fetch, # The rest is optional
$DATA, \&exists,
{%ini_value}, {%ini_existence};
DESCRIPTIONThis package allows a tied hash to autoload its values on the first access, and to use the cached value on the following accesses. Only read-accesses (via fetching the value or \*(C`exists\*(C'\fR) result in calls to the functions; the modify-accesses are performed as on a normal hash. The required arguments during \*(C`tie\*(C'\fR are the hash, the package, and the reference to the \*(C`FETCH\*(C'\fRing function. The optional arguments are an arbitrary scalar $data, the reference to the \*(C`EXISTS\*(C'\fR function, and initial values of the hash and of the existence cache. Both the \*(C`FETCH\*(C'\fRing function and the \f(CW\*(C`EXISTS\*(C'\fR functions have the same signature: the arguments are \*(C`$key, $data\*(C'\fR; \f(CW$data\fR is the same value as given as argument during tie()ing. Both functions should return an empty list if the value does not exist. If \*(C`EXISTS\*(C'\fR function is different from the \*(C`FETCH\*(C'\fRing function, it should return a TRUE value on success. The \*(C`FETCH\*(C'\fRing function should return the intended value if the key is valid.
Inheriting from Tie::MemoizeThe structure of the tied() data is an array reference with elements 0: cache of known values
1: cache of known existence of keys
2: FETCH function
3: EXISTS function
4: $data
The rest is for internal usage of this package. In particular, if TIEHASH is overwritten, it should call SUPER::TIEHASH.
EXAMPLE sub slurp {
my ($key, $dir) = shift;
open my $h, '<', "$dir/$key" or return;
local $/; <$h> # slurp it all
}
sub exists { my ($key, $dir) = shift; return −f "$dir/$key" }
tie %hash, 'Tie::Memoize', \&slurp, $directory, \&exists,
{ fake_file1 => $content1, fake_file2 => $content2 },
{ pretend_does_not_exists => 0, known_to_exist => 1 };
This example treats the slightly modified contents of $directory as a hash. The modifications are that the keys fake_file1 and fake_file2 fetch values $content1 and $content2, and pretend_does_not_exists will never be accessed. Additionally, the existence of known_to_exist is never checked (so if it does not exists when its content is needed, the user of %hash may be confused).
BUGSFIRSTKEY and NEXTKEY methods go through the keys which were already read, not all the possible keys of the hash.
AUTHORIlya Zakharevich <mailto:perl−module−hash−memoize@ilyaz.org>. 0
Johanes Gumabo
Data Size : 9,902 byte
man-Tie::Memoize.3pmBuild : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 2 / 236,141
Visitor ID : :
Visitor IP : 18.117.151.198 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|249|Tie::Memoize.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\|
) (htmlprn|149|Tie::Memoize.3pm|36/37|.el══─{─══. ds -- — |.el══─{─══. ds -- \|\(em\|
) (parse_manual_page_|249|Tie::Memoize.3pm|41|br══─}─══|'br══─}─══
) (htmlprn|149|Tie::Memoize.3pm|41|'br══─}─══ |'br══─}─══
) (rof_nr_x|149|Tie::Memoize.3pm|51/52|\nF|.ie \nF ══─{─══. de IX
) (rof_unit_scale_px|41|Tie::Memoize.3pm|51/52|F|.ie \nF ══─{─══. de IX
) (rof_if|19|Tie::Memoize.3pm|51/52|\nF|.ie \nF ══─{─══. de IX
) (htmlprn|149|Tie::Memoize.3pm|51/52|.ie \nF ══─{─══. de IX|.ie \nF ══─{─══. de IX
) (rof_escape_sequence|91|Tie::Memoize.3pm|53|\$1\t\\n%\t"\\$2" |. tm Index:\\$1\t\\n%\t"\\$2"
) (parse_manual_page_|249|Tie::Memoize.3pm|57|══─}─══|.══─}─══
) (htmlprn|149|Tie::Memoize.3pm|57|.══─}─══ |.══─}─══
) (rof_escape_sequence|91|Tie::Memoize.3pm|148|\*(C`exists\*(C'\fR) result in calls to |Only read-accesses (via fetching the value or \f(CW\*(C`exists\*(C'\fR) result in calls to
) (rof_escape_sequence|91|Tie::Memoize.3pm|151|\*(C`tie\*(C'\fR are the hash, the package, and |The required arguments during \f(CW\*(C`tie\*(C'\fR are the hash, the package, and
) (rof_escape_sequence|91|Tie::Memoize.3pm|152|\*(C`FETCH\*(C'\fRing function. The optional arguments are |the reference to the \f(CW\*(C`FETCH\*(C'\fRing function. The optional arguments are
) (rof_escape_sequence|91|Tie::Memoize.3pm|153|\*(C`EXISTS\*(C'\fR function, |an arbitrary scalar \f(CW$data\fR, the reference to the \f(CW\*(C`EXISTS\*(C'\fR function,
) (rof_escape_sequence|91|Tie::Memoize.3pm|156|\*(C`FETCH\*(C'\fRing function and the \f(CW\*(C`EXISTS\*(C'\fR functions have the |Both the \f(CW\*(C`FETCH\*(C'\fRing function and the \f(CW\*(C`EXISTS\*(C'\fR functions have the
) (rof_escape_sequence|91|Tie::Memoize.3pm|157|\*(C`$key, $data\*(C'\fR; \f(CW$data\fR is the same |same signature: the arguments are \f(CW\*(C`$key, $data\*(C'\fR; \f(CW$data\fR is the same
) (rof_escape_sequence|91|Tie::Memoize.3pm|159|\*(C`EXISTS\*(C'\fR |return an empty list if the value does not exist. If \f(CW\*(C`EXISTS\*(C'\fR
) (rof_escape_sequence|91|Tie::Memoize.3pm|160|\*(C`FETCH\*(C'\fRing function, it should return |function is different from the \f(CW\*(C`FETCH\*(C'\fRing function, it should return
) (rof_escape_sequence|91|Tie::Memoize.3pm|161|\*(C`FETCH\*(C'\fRing function should return the |a \s-1TRUE\s0 value on success. The \f(CW\*(C`FETCH\*(C'\fRing function should return the
)