WWW :: Mechanize :: Cached - 问题

sid*_*com 1 perl caching www-mechanize

当我使用默认值的WWW :: Mechanize :: Cached时,一切正常.

#!/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 );
Run Code Online (Sandbox Code Playgroud)

但是当我试图变得聪明并选择我自己的论点时,似乎缓存不起作用:每次运行脚本时我都有网络流量并且没有及时获得.

#!/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), driver => '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 );
Run Code Online (Sandbox Code Playgroud)

我能做些什么,让第二个例子有效?

Eri*_*sty 5

使用driver =>'Memory',缓存不会保留在磁盘上 - 将驱动程序更改为'File'或磁盘上的其他内容.