The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

WebService::Amazon::Route53::Caching - Caching layer for the Amazon Route 53 API

SYNOPSIS

WebService::Amazon::Route53::Caching provides an caching layer on top of the existing WebService::Amazon::Route53 module, which presents an interface to the Amazon Route 53 DNS service.

DESCRIPTION

This module overrides the base behaviour of the WebService::Amazon::Route53 object to provide two specific speedups:

We force the use of HTTP Keep-Alive when accessing the remote Amazon API end-point.
We cache the mapping between zone-names and Amazon IDs

The reason for the existance of this module was observed performance issues with the native client. A user of the Route53 API wishes to use the various object methods against zones, but the Amazon API requires that you use their internal IDs.

For example rather than working with a zone such as "steve.org.uk", you must pass in a zone_id of the form "123ZONEID". Discovering the ID of a zone is possible via get_hosted_zone method.

Unfortunately the implementation of the get_hosted_zone method essentially boils down to fetching all possible zones, and then performing a string comparison on their names.

This module was born to cache the ID-data of individual zones, allowing significant speedups when dealing with a number of zones.

CACHING

This module supports two different types of caching:

Caching via the fast in-memory datastore, Redis.
Caching via the DB_File module.

To specify the method you need to pass the appropriate argument to the constructor of this class.

The simplest approach involves passing a filename to use as the DB-store:

    my $c = WebService::Amazon::Route53::Caching->new( key => "xx",
                                                       id  => "xx",
                                                       path => "/tmp/x.db" );

    $c->....

The following example uses Redis :

    my $r = new Redis;

    my $c = WebService::Amazon::Route53::Caching->new( key => "xx",
                                                       id  => "xx",
                                                       redis => $r );

    $c->....

All other class methods remain identical to those implemented in the parent.