Masahiro Nagano

NAME

DBIx::DSN::Resolver::Cached - Cached resolver for DBIx::DSN::Resolver

SYNOPSIS

  use 5.10.0;
  use DBIx::DSN::Resolver::Cached;

  sub connect_db {
      state $resolver = DBIx::DSN::Resolver::Cached->new(
          ttl => 30,
          negative_ttl => 5,
      );
      my $dsn = $resolver->resolv('dbi:mysql:database=mytbl;host=myserver.example');
      DBI->connect($dsn,'user','password');
  }

DESCRIPTION

DBIx::DSN::Resolver::Cached is extension module of DBIx::DSN::Resolver. This module allows CACHE resolver response, useful for reduce load of DNS. DBIx::DSN::Resolver::Cached also supports DNS-RR

OPTIONS

ttl: Int

positive cache ttl in seconds. (default: 5)

negative_ttl: Int

negative cache ttl in seconds. (default: 1)

cache: Object

Cache object, requires support get and set methods. default: Cache::Memory::Simple is used

FUNCTION

dsn_resolver($dsn: Str)

shortcut function for

  state $resolver = DBIx::DSN::Resolver::Cached->new();
  $resolver->resolv('dbi:mysql:database=mytbl;host=myserver.example')

To customize ttl, negative_ttl and cache object. override $DBIx::DSN::Resolver::Cached::RESOLVER

  my $other_ttl = DBIx::DSN::Resolver::Cached->new(
        ttl => ..
  );
  sub {
      local $DBIx::DSN::Resolver::Cached::RESOLVER = $other_ttl;
      dsn_resolver($dsn);
  }

AUTHOR

Masahiro Nagano <kazeburo {at} gmail.com>

SEE ALSO

DBIx::DSN::Resolver, Cache::Memory::Simple

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.




Hosting generously
sponsored by Bytemark