Cache-Elasticache-Memcache

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

         "requires" : {
            "Dist::Milla" : "v1.0.15",
            "Test::Pod" : "1.41"
         }
      },
      "runtime" : {
         "requires" : {
            "Cache::Memcached::Fast" : "0",
            "Carp" : "0",
            "IO::Socket::IP" : "0",
            "IO::Socket::Timeout" : "0",
            "Try::Tiny" : "0",
            "perl" : "5.008008"
         }
      },
      "test" : {
         "requires" : {
            "Moo" : "0",
            "Sub::Override" : "0",
            "Test::Deep" : "0",
            "Test::Exception" : "0",

META.yml  view on Meta::CPAN

    - eg
    - examples
    - inc
    - share
    - t
    - xt
requires:
  Cache::Memcached::Fast: '0'
  Carp: '0'
  IO::Socket::IP: '0'
  IO::Socket::Timeout: '0'
  Try::Tiny: '0'
  perl: '5.008008'
resources:
  bugtracker: https://github.com/zebardy/cache-memcache-elasticache/issues
  homepage: https://github.com/zebardy/cache-memcache-elasticache
  repository: https://github.com/zebardy/cache-memcache-elasticache.git
version: 0.0.5
x_contributors:
  - 'Aaron Moses <mosesa02@localhost.localdomain>'
  - 'Aaron Moses <zebardy@gmail.com>'

Makefile.PL  view on Meta::CPAN

    "ExtUtils::MakeMaker" => 0
  },
  "DISTNAME" => "Cache-Elasticache-Memcache",
  "LICENSE" => "perl",
  "MIN_PERL_VERSION" => "5.008008",
  "NAME" => "Cache::Elasticache::Memcache",
  "PREREQ_PM" => {
    "Cache::Memcached::Fast" => 0,
    "Carp" => 0,
    "IO::Socket::IP" => 0,
    "IO::Socket::Timeout" => 0,
    "Try::Tiny" => 0
  },
  "TEST_REQUIRES" => {
    "Moo" => 0,
    "Sub::Override" => 0,
    "Test::Deep" => 0,
    "Test::Exception" => 0,
    "Test::MockObject" => 0,
    "Test::More" => 0,
    "Test::Pod" => 0,

Makefile.PL  view on Meta::CPAN

  "test" => {
    "TESTS" => "t/*.t"
  }
);


my %FallbackPrereqs = (
  "Cache::Memcached::Fast" => 0,
  "Carp" => 0,
  "IO::Socket::IP" => 0,
  "IO::Socket::Timeout" => 0,
  "Moo" => 0,
  "Sub::Override" => 0,
  "Test::Deep" => 0,
  "Test::Exception" => 0,
  "Test::MockObject" => 0,
  "Test::More" => 0,
  "Test::Pod" => 0,
  "Test::Routini" => 0,
  "Try::Tiny" => 0
);

cpanfile  view on Meta::CPAN

requires 'perl', '5.008008';
requires 'Cache::Memcached::Fast';
requires 'IO::Socket::IP';
requires 'IO::Socket::Timeout';
requires 'Carp';
requires 'Try::Tiny';

on develop => sub {
#    requires 'Dist::Milla';
};

on test => sub {
    requires 'Test::Routini';
    requires 'Test::More';

lib/Cache/Elasticache/Memcache.pm  view on Meta::CPAN

A wrapper for L<Cache::Memacached::Fast> with support for AWS's auto reconfiguration mechanism. It makes use of an AWS elasticache memcached cluster's configuration endpoint to discover the memcache servers in the cluster and periodically check the c...

=head1 UNDER DEVELOPMENT DISCALIMER

N.B. This module is still under development. It should work, but things may change under the hood. I plan to imporove the resiliance with better timeout handling of communication when updating the server list. I'm toying with the idea of making the s...

=cut

use Carp;
use IO::Socket::IP;
use IO::Socket::Timeout;
use Cache::Memcached::Fast;
use Try::Tiny;
use Scalar::Util qw(blessed);

our $VERSION = '0.0.5';

=pod

=head1 CONSTRUCTOR

lib/Cache/Elasticache/Memcache.pm  view on Meta::CPAN

    my $config_endpoint = shift;
    my $data = "";
    # TODO: make use of "connect_timeout" (default 0.5s) and "io_timeout" (default 0.2s) constructor parameters
    # my $args = shift;
    # $connect_timeout = exists $args->{connect_timeout} ? $args->{connect_timeout} : $class::default_connect_timeout;
    # $io_timeout = exists $args->{io_timeout} ? $args->{io_timeout} : $class::default_io_timeout;
    my $socket = (blessed($invoker)) ? $invoker->{_sockets}->{$config_endpoint} : undef;

    for my $i (0..2) {
        unless (defined $socket && $socket->connected()) {
            $socket = IO::Socket::IP->new(PeerAddr => $config_endpoint, Timeout => 10, Proto => 'tcp');
            croak "Unable to connect to server: ".$config_endpoint." - $!" unless $socket;
            $socket->sockopt(SO_KEEPALIVE,1);
            $socket->autoflush(1);
            IO::Socket::Timeout->enable_timeouts_on($socket);
            $socket->read_timeout(0.5);
# This is currently commented out as it was breaking under perl 5.24 for me. Need to investigate!
#            $socket->write_Timeout(0.5);
        }

        try {
            $socket->send("config get cluster\r\n");
            my $count = 0;
            until ($data =~ m/END/) {
                my $line = $socket->getline();
                if (defined $line) {
                    $data .= $line;
                }

t/basic.t  view on Meta::CPAN


has parent_overrides => (
    is => 'ro',
    default => sub {
        my $self = shift;
        my $mock = Test::MockObject->new(gensym);
        $mock->set_isa('IO::Socket');
        $mock->mock('autoflush', sub { return 1 });
        $mock->mock('sockopt', sub { return 1 });
        $mock->mock('setsockopt', sub { return 1 });
        $mock->mock('write_Timeout', sub { return 1 });
        $mock->mock('send', sub { return 1 });
        my @lines = @{$self->config_lines};
        $mock->mock('getline', sub { return shift @lines });
        $mock->mock('close', sub { return 1 });
        my $overrides = Sub::Override->new()
                                     ->replace('Cache::Memcached::Fast::new' , sub { my $object = shift; my @args = @_; $self->last_parent_object($object); $self->last_parent_args(\@args) })
                                     ->replace('Cache::Memcached::Fast::DESTROY' , sub { })
                                     ->replace('IO::Socket::IP::new', sub{ my $object = shift; my @args = @_; croak "config_endpoint:-".{@args}->{'PeerAddr'} unless {@args}->{'PeerAddr'} eq 'good:11211'; return $mock });
        return $overrides;
    }

t/config_endpoint.t  view on Meta::CPAN

}

sub build_mock_socket {
    my $self = shift;
    my $config_lines = shift;
    my $glob = shift;
    my %args = @_;

    my $mock = Test::MockObject->new($glob);
    $mock->set_isa('IO::Socket');
    foreach my $method (qw(autoflush sockopt send close connected setsockopt write_Timeout)) {
        $mock->mock($method, (exists $args{$method}) ? $args{$method} : $self->default_mock_method($method));
    }
    my @lines = @{$config_lines};
    $mock->mock('getline', sub { return shift @lines });

   return $mock;
}

sub default_mock_method {
    my $self = shift;



( run in 0.274 second using v1.01-cache-2.11-cpan-4d50c553e7e )