From: Dirk Vleugels Date: Tue, 23 Mar 2010 17:10:36 +0000 (+0100) Subject: uses only the multi-bulk protocol X-Git-Url: http://git.rot13.org/?p=perl-Redis.git;a=commitdiff_plain;h=748f1216489a7007e21f1caa28499d46b3e5aadc;hp=213be1cb5cb9f4164697787ee3117d193061d67c uses only the multi-bulk protocol http://groups.google.com/group/redis-db/browse_thread/thread/4b266d0f6f11d9ba/adf47fd931f62787 --- diff --git a/lib/Redis.pm b/lib/Redis.pm index 55fd1a1..75bc088 100644 --- a/lib/Redis.pm +++ b/lib/Redis.pm @@ -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 {} @@ -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;