more strict argument checks for Cache::Memcached->new

Brad Fitzpatrick brad at danga.com
Mon Jul 2 23:00:33 UTC 2007


Good catch.

Either way, %hash or $hashref, works as of 1.24 (to be released soon
here).


On Tue, 8 May 2007, Tokuhiro Matsuno wrote:

> I think, Cache::Memcached->new(servers => ['127.0.0.1:11211']) makes
> very difficult to detect bug.
> Please add the more strict checks.
>
> Index: lib/Cache/Memcached.pm
> ===================================================================
> --- lib/Cache/Memcached.pm      (revision 555)
> +++ lib/Cache/Memcached.pm      (working copy)
> @@ -11,6 +11,7 @@
>  use warnings;
>
>  no strict 'refs';
> +use Carp;
>  use Storable ();
>  use Socket qw( MSG_NOSIGNAL PF_INET PF_UNIX IPPROTO_TCP SOCK_STREAM );
>  use IO::Handle ();
> @@ -65,6 +66,7 @@
>      $self = fields::new( $self ) unless ref $self;
>
>      my ($args) = @_;
> +    croak "Cache::Memcached->new required hashref: $args" unless ref
> $args eq "HASH";
>
>      $self->set_servers($args->{'servers'});
>      $self->{'debug'} = $args->{'debug'} || 0;
>
>


More information about the memcached mailing list