confess dump($ok) unless $ok eq "+OK\r\n";
}
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
=head1 Connection Handling
=head2 quit
- 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 );
+=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<< <dpavlin at rot13.org> >>
=head1 AUTHOR
Dobrica Pavlinusic, C<< <dpavlin at rot13.org> >>
use warnings;
use strict;
use warnings;
use strict;
-use Test::More tests => 53;
+use Test::More tests => 54;
ok( my $nr_keys = $o->dbsize, 'dbsize' );
diag "dbsize: $nr_keys";
ok( my $nr_keys = $o->dbsize, 'dbsize' );
diag "dbsize: $nr_keys";
+diag "Commands operating on lists";
+
+ok( $o->rpush( 'test-list' => 'foo' ), 'rpush' );
+
+
+
+