New on CPAN - MooseX::CachingProxy
Last week I released MooseX::CachingProxy to CPAN.
Its a small module that intercepts requests from your LWP based application. Those requests are relayed on to the intended server unless they already exist in the cache.
To toggle on and off the caching proxy, MooseX::CachingProxy provides the attribute ‘caching_proxy’. Here is a quick demo:
package MyApp;
use Moose;
use WWW::Mechanize; # or any LWP based library
with 'MooseX::CachingProxy';
sub url { 'http://example.com' } # required by MooseX::CachingProxy
sub download {
my $self = shift;
$self->start_caching_proxy;
return WWW::Mechanize->new()->get($self->url . '/foo');
}
Under the covers, its a tiny Plack application that mashes up Plack::Middleware::Cache and Plack::App::Proxy.
Nice! You read all the way to the bottom of this post. You might find my
book Minimum Viable Perl useful. It contains concise tutorials for
experienced developers. Its free, open source, and a work in progress.
Subscribe to get new
chapters in your inbox.