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
|