logo       

Re: Memoizing some but not all calls: msg#00018

Subject: Re: Memoizing some but not all calls
On Sun, 6 Mar 2005, Scott Roland wrote:

>The problem is that after I fetch $base to reset my cookie I want to
>refetch the day listing, but it is memoized, so I end up getting the
>cached error message back.

>Instead I can go in almost the opposite direction and create a
>wrapper fetch_day() function that handles the error message and does
>a refetch. Then instead of memoizing XMLTV::Get_nice::get_nice_aux()
>I can memoize fetch_day().

Yes, this is the right way to do it.

>I still want to memoize my individual program descriptions, but I
>can't memoize XMLTV::Get_nice::get_nice_aux because of above. So I
>created a new function get_nice_memo() and call it where I used to
>call get_nice()  and still want it to be memoized. And then I also
>memoize get_nice_memo().

OK.

>XMLTV::Get_nice.pm has an odd hack using scalar casting and noting
>that get_nice() should be called, but get_nice_aux() is the function
>to be memoized. After my changes I am memoizing and calling the same
>function in get_nice_memo(); I don't see any problems, is this okay?

Er, yes, if it works it works.  The whole business with scalar versus
list context is a bit nasty.

The code snippet you included looks good.  Can you confirm that if you
run the grabber twice with --cache then the second time it does no
page fetches from the network and gives exactly the same output?

-- 
Ed Avis <ed@xxxxxxxxxxx>





-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe