--- lib/Redis.pm 2009/03/21 22:54:10 9 +++ lib/Redis.pm 2009/03/21 23:05:02 10 @@ -119,6 +119,14 @@ =cut +sub sock_result { + my $result = <$sock>; + warn "# result: ",dump( $result ); + $result =~ s{\r\n$}{} || warn "can't find cr/lf"; + return $result; +} + + sub incr { my ( $self, $key, $value ) = @_; if ( defined $value ) { @@ -126,9 +134,7 @@ } else { print $sock "INCR $key\r\n"; } - my $count = <$sock>; - warn "# $key = $count"; - return $count; + sock_result(); } =head2 decr @@ -145,9 +151,7 @@ } else { print $sock "DECR $key\r\n"; } - my $count = <$sock>; - warn "# $key = $count"; - return $count; + sock_result(); } =head2 exists @@ -159,10 +163,19 @@ sub exists { my ( $self, $key ) = @_; print $sock "EXISTS $key\r\n"; - my $found = <$sock>; - $found =~ s{\r\n$}{}; - warn "# exists $key = $found"; - return $found; + sock_result(); +} + +=head2 del + + $r->del( 'key' ) || warn "key doesn't exist"; + +=cut + +sub del { + my ( $self, $key ) = @_; + print $sock "DEL $key\r\n"; + sock_result(); } =head1 AUTHOR