WWW::Mechanize::Cached - question
When I use WWW::Mechanize::Cached with default values all works fine.
#!/usr/bin/env perl
use warnings;
use 5.012;
use WWW::Mechanize::Cached;
my $uri = 'http://www.some_address';
my $mech = WWW::Mechanize::Cached->new();
$mech->show_progress( 1 );
$mech->get( $uri );
But when I try to be smart and choose my own arguments, it seems the caching is not working: each time I run the script I have network-traffic and no gain in time.
#!/usr/bin/env perl
use warnings;
use 5.012;
use Cwd qw(realpath);
use WWW::Mechanize::Cached;
use CHI;
my $uri = 'http://www.some_address';
my $cache = CHI->new( namespace => realpath($0), driv开发者_运维技巧er => 'Memory',
expires_in => '60 min', expires_variance => 0.25, global => 1 );
my $mech = WWW::Mechanize::Cached->new( cache => $cache );
$mech->show_progress( 1 );
$mech->get( $uri );
What could I do, to make the second example work?
With driver => 'Memory', the cache won't persist on disk -- change the driver to 'File' or something else that's on disk.
精彩评论