--- lib/Redis.pm 2009/03/21 22:20:51 5 +++ lib/Redis.pm 2009/03/21 22:54:10 9 @@ -112,7 +112,58 @@ 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; +} + +=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; +} + +=head2 exists + + $r->exists( 'key' ) && print "got key!"; + +=cut + +sub exists { + my ( $self, $key ) = @_; + print $sock "EXISTS $key\r\n"; + my $found = <$sock>; + $found =~ s{\r\n$}{}; + warn "# exists $key = $found"; + return $found; +} =head1 AUTHOR