Memoize

 view release on metacpan or  search on metacpan

TODO  view on Meta::CPAN

=pod

=over 4

=item * 

LIST_CACHE doesn't work with ties to most DBM implementations, because
Memoize tries to save a listref, and DB_File etc. can only store
strings.  This should at least be documented.  Maybe Memoize could
detect the problem at TIE time and throw a fatal error.

20010623 This was added sometime prior to 20001025.

Try out MLDBM here and document it if it works.

=item * 

Perhaps C<memoize> should return a reference to the original function
as well as one to the memoized version?  But the programmer could
always construct such a reference themselves, so perhaps it's not
necessary.  We save such a reference anyway, so a new package method
could return it on demand even if it wasn't provided by C<memoize>.
We could even bless the new function reference so that it could have
accessor methods for getting to the original function, the options,
the memo table, etc.

Naah.

=item *

Maybe an option for automatic expiration of cache values?  (`After one
day,' `After five uses,' etc.)  Also possibly an option to limit the
number of active entries with automatic LRU expiration.

You have a long note to Mike Cariaso that outlines a good approach
that you sent on 9 April 1999.

What's the timeout stuff going to look like?

	EXPIRE_TIME => time_in_sec
	EXPIRE_USES => num_uses
	MAXENTRIES => n

perhaps?  Is EXPIRE_USES actually useful?

19990916: Memoize::Expire does EXPIRE_TIME and EXPIRE_USES.
MAXENTRIES can come later as a separate module.

=item *

Put in a better example than C<fibo>.  Show an example of a
nonrecursive function that simply takes a long time to run.
C<getpwuid> for example?  But this exposes the bug that you can't say
C<memoize('getpwuid')>, so perhaps it's not a very good example.

Well, I did add the ColorToRGB example, but it's still not so good.
These examples need a lot of work.  C<factorial> might be a better
example than C<fibo>.  

=item *

Include an example that caches DNS lookups.

=item *

Make tie for DBI  (Memoize::DBI)

=item *

Maybe the default for LIST_CACHE should be MERGE anyway.

=item * 

Maybe if the original function has a prototype, the module can use
that to select the most appropriate default normalizer.  For example,
if the prototype was C<($)>, there's no reason to use `join'.  If it's
C<(\@)> then it can use C<join $;,@$_[0];> instead of C<join $;,@_;>.

=item *

Ariel Scolnikov suggests using the change counting problem as an
example.  (How many ways to make change of a dollar?)

=item * 

Jonathan Roy found a use for `unmemoize'.  If you're using the
Storable glue, and your program gets SIGINT, you find that the cache
data is not in the cache, because Perl normally writes it all out at
once from a DESTROY method, and signals skip DESTROY processing.  So
you could add

	$sig{INT} = sub { unmemoize ... };


=item *

This means it would be useful to have a method to return references to
all the currently-memoized functions so that you could say

	$sig{INT} = sub { for $f (Memoize->all_memoized) {
	                    unmemoize $f;
	                  }
	                }


=item *

19990917 There should be a call you can make to get back the cache
itself.  If there were, then you could delete stuff from it to
manually expire data items.

=item *

19990925 Randal says that the docs for Memoize;:Expire should make it



( run in 1.594 second using v1.01-cache-2.11-cpan-5837b0d9d2c )