X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=lib%2FRedis.pm;h=75bc0880bf282f271b1d6e87697ec1085a88796b;hb=748f1216489a7007e21f1caa28499d46b3e5aadc;hp=82aeae0469b0a02224ac53838c1e68a178f7ba88;hpb=49804f1841733d8eee5bae43b0d1e2e68aa4486b;p=perl-Redis.git diff --git a/lib/Redis.pm b/lib/Redis.pm index 82aeae0..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; @@ -372,6 +342,14 @@ See also L for tie interface. my $info_hash = $r->info; +=head1 ENCODING + +Since Redis knows nothing about encoding, we are forcing utf-8 flag on all data received from Redis. +This change is introduced in 1.2001 version. + +This allows us to round-trip utf-8 encoded characters correctly, but might be problem if you push +binary junk into Redis and expect to get it back without utf-8 flag turned on. + =head1 AUTHOR Dobrica Pavlinusic, C<< >>