manually expire an element in Memoize (also on comp.lang.perl.misc)
am 14.02.2007 23:52:04 von Daniel McBreartyhi all
I like and use MJ Dominus' excellent Memoize module to cache some
stuff in my app that hits a db rather hard. It's very simple :
use Memoize;
memoize('my_accessor');
sub my_accessor {
my ($key1, $key2) = @_;
# look up $key1, $key2 in the db and return a scalar
}
and the function is magically cached without the need to do any more.
Now what I'd like is, in another function, to manually invalidate (or
delete) certain cached values at runtime (most likely because I
changed the value in the db).
How can I do this? I looked at the docs and source for
Memoize::Expire, but it's not too clear to me right now. Obviously,
I'd like the simplest possible solution ...
thanks
Daniel
(apologies for the cross post to comp.lang.perl.misc - this would have
been a better choice of group from the off ... )