I released AnyEvent::DNS::Cache::Simple to cpan today.
cpan: https://metacpan.org/release/AnyEvent-DNS-Cache-Simple
github: https://github.com/kazeburo/AnyEvent-DNS-Cache-Simple
This module will cache DNS responses of AnyEvent::DNS. And you can improve the performance of AnyEvent applications.
synopsis
use AnyEvent::HTTP;
use AnyEvent::DNS::Cache::Simple;
use Cache::LRU::WithExpires;
my $cache = Cache::LRU::WithExpires->new;
my $guard = AnyEvent::DNS::Cache::Simple->register(
ttl => 60,
negative_ttl => 5,
timeout => [1,1],
cache => $cache # default uses Cache::Memory::Simple
);
for my $i ( 1..3 ) {
my $cv = AE::cv;
http_get "http://mixi.jp/", sub {
say "get $i";
$cv->send;
};
$cv->recv;
}
undef $guard;
# not using cahce
my $cv = AE::cv;
http_get "http://mixi.jp/", sub {
warn "get 4";
$cv->send;
};
$cv->recv;
AnyEvent::DNS::Cache::Simple というモジュールをリリースしました。AnyEvent::DNSの問い合わせ結果をキャッシュしてAnyEventを利用したアプリケーションのパフォーマンスを向上させることができます。