in reply to Wanted: LWP::Cache

There isn't a module specific for LWP that I know off, but I don't think one is needed (see Cache::Cache).

update: On second thought, transparently handling things sounds good, go for it.

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
2Re: Wanted: LWP::Cache
by jeffa (Bishop) on Aug 04, 2003 at 19:43 UTC
    I know you already know all of this, but i replied to you because it seemed like the place. ;) I just had to take a stab at this:
    use strict; use warnings; use LWP::Simple; use Cache::MemoryCache; my $cache = Cache::MemoryCache->new({ namespace => 'MyNamespace', default_expires_in => 60, }); for (1..3) { my $page = $cache->get('perlmonks'); unless ($page) { warn "fetching from web\n"; $page = get('http://perlmonks.org'); $cache->set('perlmonks', $page, "1 minute" ); } else { warn "fetching from cache\n"; } }
    The for loop is just to actually show that subsequent fetches (after the first) come from the memory cache and not the web. Use Cache::FileCache if you want persistence past the life of script execution.

    Honestly, as easy as this is ... it's still 'plumbing'. I would like to see a 'LWP::Cache' module as long as it is a transparent wrapper around LWP and Cache::Cache. Why not? ;)

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)