Skip to content

Commit

Permalink
uses only the multi-bulk protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
netrek-zz authored and dpavlin committed Mar 23, 2010
1 parent 213be1c commit 748f121
Showing 1 changed file with 5 additions and 35 deletions.
40 changes: 5 additions & 35 deletions lib/Redis.pm
Expand Up @@ -55,22 +55,6 @@ sub new {
$self;
}

my $bulk_command = {
set => 1, setnx => 1,
rpush => 1, lpush => 1,
lset => 1, lrem => 1,
sadd => 1, srem => 1,
sismember => 1,
echo => 1,
getset => 1,
smove => 1,
zadd => 1,
zrem => 1,
zscore => 1,
zincrby => 1,
append => 1,
};

# we don't want DESTROY to fallback into AUTOLOAD
sub DESTROY {}

Expand All @@ -87,27 +71,13 @@ sub AUTOLOAD {

warn "## $command ",Dumper(@_) if $self->{debug};

my $send;

if ( defined $bulk_command->{$command} ) {
my $value = pop;
$value = '' if ! defined $value;
$send
= uc($command)
. ' '
. join(' ', @_)
. ' '
. length( $value )
. "\r\n$value\r\n"
;
} else {
$send
= uc($command)
. ' '
. join(' ', @_)
unshift @_, uc($command);

my $send
= "*".(scalar @_)
. "\r\n"
. join("", map { "\$". length($_) ."\r\n". $_ ."\r\n" } @_)
;
}

warn ">> $send" if $self->{debug};
print $sock $send;
Expand Down

0 comments on commit 748f121

Please sign in to comment.