Click here to get back home

manually expire an element in Memoize (also on comp.lang.perl.misc)

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
manually expire an element in Memoize (also on comp.lang.perl.misc) danielmcbrearty 02-14-2007
Posted by danielmcbrearty on February 14, 2007, 5:52 pm
Please log in for more thread options


hi 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 ... )


Posted by Javier M Mora (jamarier) on February 15, 2007, 1:58 pm
Please log in for more thread options


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

danielmcbrearty@gmail.com escribió:
On 14 Feb 2007 14:52:04 -0800, danielmcbrearty@gmail.com wrote:
> 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 :
> [...]
> 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?

If you read Memoize doc, you can see HASH option. You can set/get hash
where the memoize info is. You only need clear key of data you want
invalidate.

javier m mora.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFF1KzYpRHCj3lPPYMRAvi9AJ9TcgfxzUb9UaQ7GU5ci896BQGk6gCgmiMD
PCZI9XNJyG6f0fbZehSJCXM=
=cV4d
-----END PGP SIGNATURE-----

Similar ThreadsPosted
comp.lang.perl.modules February 10, 2006, 2:33 pm
comp.lang.perl.modules charter April 21, 2008, 10:29 pm
revised comp.lang.perl.modules charter January 7, 2006, 1:07 pm
comp.lang.perl.modules security issues October 18, 2006, 12:59 am
comp.lang.perl.modules,alt.autos.rod-n-custom,alt.kids-talk,alt.internet.p2p,alt.support.nutty.as.a.fruitcake December 28, 2004, 2:24 am
alt.sports.football.pro.wash-redskins,alt.books.ghost-fiction,alt.sports.college.utexas,comp.lang.perl.modules,alt.autos.porsche December 12, 2004, 3:54 am
perl xml check for element closure November 18, 2006, 9:26 pm
GD::Graph => How to set maximum value manually on Y ? October 6, 2004, 6:35 pm
Accessing the Memoize cache April 2, 2005, 1:15 am
problems with Memoize::Storable February 22, 2007, 4:54 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap