return $v;
}
+=head2 incr
+ $r->incr('counter');
+ $r->incr('tripplets', 3);
+
+=cut
+
+sub incr {
+ my ( $self, $key, $value ) = @_;
+ if ( defined $value ) {
+ print $sock "INCRBY $key $value\r\n";
+ } else {
+ print $sock "INCR $key\r\n";
+ }
+ my $count = <$sock>;
+ warn "# $key = $count";
+ return $count;
+}
=head1 AUTHOR
use warnings;
use strict;
-use Test::More tests => 18;
+use Test::More tests => 28;
use lib 'lib';
ok( ! $o->get( 'non-existant' ), 'get non-existant' );
-foreach ( 0 .. 3 ) {
+ok( $o->set('key-next' => 0), 'key-next = 0' );
+
+my $key_next = 3;
+
+foreach ( 0 .. $key_next ) {
ok( $o->set( "key-$_" => $_ ), "set key-$_" );
cmp_ok( $o->get( "key-$_" ), 'eq', $_, "get key-$_" );
+ cmp_ok( $o->incr( 'key-next' ), '==', $_ + 1, 'incr' );
+}
+
+cmp_ok( $o->get( 'key-next' ), '==', $key_next + 1, 'key-next' );
+
+ok( $o->set('test-incrby', 0), 'test-incrby' );
+foreach ( 1 .. 3 ) {
+ cmp_ok( $o->incr('test-incrby', 3), '==', $_ * 3, 'incrby 3' );
}
ok( $o->quit, 'quit' );