return $count;
}
+=head2 decr
+
+ $r->decr('counter');
+ $r->decr('tripplets', 3);
+
+=cut
+
+sub decr {
+ my ( $self, $key, $value ) = @_;
+ if ( defined $value ) {
+ print $sock "DECRBY $key $value\r\n";
+ } else {
+ print $sock "DECR $key\r\n";
+ }
+ my $count = <$sock>;
+ warn "# $key = $count";
+ return $count;
+}
+
=head1 AUTHOR
Dobrica Pavlinusic, C<< <dpavlin at rot13.org> >>
use warnings;
use strict;
-use Test::More tests => 28;
+use Test::More tests => 37;
use lib 'lib';
my $key_next = 3;
+ok( $o->set('key-left' => $key_next), 'key-left' );
+
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->decr( 'key-left' ), '==', $key_next - $_ - 1, 'decr' );
}
cmp_ok( $o->get( 'key-next' ), '==', $key_next + 1, 'key-next' );
ok( $o->set('test-incrby', 0), 'test-incrby' );
+ok( $o->set('test-decrby', 0), 'test-decry' );
foreach ( 1 .. 3 ) {
cmp_ok( $o->incr('test-incrby', 3), '==', $_ * 3, 'incrby 3' );
+ cmp_ok( $o->decr('test-decrby', 7), '==', -( $_ * 7 ), 'decrby 7' );
}
ok( $o->quit, 'quit' );