FP::Memoizing - a functional memoize
use FP::Memoizing qw(memoizing memoizing_to_dir); use Chj::tempdir; my $tmp = do{ mkdir ".tmp"; tempdir ".tmp/" }; my $count = 0; sub f { $count++; $_[0] * 5 } *fm = memoizing \&f; # memoize in process memory *fm2 = memoizing_to_dir $tmp, \&f; # memoize to files in ".foo/" is fm(3), 15; is $count, 1; is fm(3), 15; is $count, 1; is fm(2), 10; is $count, 2; is fm2(3), 15; is $count, 3; is fm2(3), 15; is $count, 3;
No locking whatsoever is currently being done.
Also, serializes twice in different ways, for the key and the actual storage. Could Storable be used for the key as well?
This is alpha software! Read the status section in the package README or on the website.
To install FunctionalPerl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm FunctionalPerl
CPAN shell
perl -MCPAN -e shell install FunctionalPerl
For more information on module installation, please visit the detailed CPAN module installation guide.