X-Git-Url: http://git.rot13.org/?p=perl-Redis.git;a=blobdiff_plain;f=lib%2FRedis.pm;h=484e9b1aaf546efc6dccedc44b68dbbaf9551383;hp=a2b8647b226d5306a86075a6b8afe14323123bbd;hb=b8c759eed57f05e57445c661a30cab09a5fb2707;hpb=74f09579425ad6060edc98c31b7781b57c5fecde diff --git a/lib/Redis.pm b/lib/Redis.pm index a2b8647..484e9b1 100644 --- a/lib/Redis.pm +++ b/lib/Redis.pm @@ -75,6 +75,13 @@ sub _sock_ok { confess dump($ok) unless $ok eq "+OK\r\n"; } +sub _sock_send_bulk { + my ( $self, $command, $key, $value ) = @_; + print $sock "$command $key " . length($value) . "\r\n$value\r\n"; + _sock_ok(); +} + + =head1 Connection Handling =head2 quit @@ -110,9 +117,8 @@ sub ping { =cut sub set { - my ( $self, $k, $v, $new ) = @_; - print $sock "SET" . ( $new ? 'NX' : '' ) . " $k " . length($v) . "\r\n$v\r\n"; - _sock_ok(); + my ( $self, $key, $value, $new ) = @_; + $self->_sock_send_bulk( "SET" . ( $new ? 'NX' : '' ), $key, $value ); } =head2 get @@ -249,6 +255,19 @@ sub dbsize { _sock_result(); } +=head1 Commands operating on lists + +=head2 rpush + + $r->rpush( $key, $value ); + +=cut + +sub rpush { + my ( $self, $key, $value ) = @_; + $self->_sock_send_bulk('RPUSH', $key, $value); +} + =head1 AUTHOR Dobrica Pavlinusic, C<< >>