From 7b0869dd4683fb3bd7abbe772e70027e37808d8f Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 21 Mar 2009 23:09:48 +0000 Subject: [PATCH] make _sock_result private, type git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/Redis@11 447b33ff-793d-4489-8442-9bea7d161be5 --- lib/Redis.pm | 33 +++++++++++++++++++++++---------- t/01-Redis.t | 4 +++- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/lib/Redis.pm b/lib/Redis.pm index c5597df..039fade 100644 --- a/lib/Redis.pm +++ b/lib/Redis.pm @@ -51,6 +51,13 @@ sub new { $self; } +sub _sock_result { + my $result = <$sock>; + warn "# result: ",dump( $result ); + $result =~ s{\r\n$}{} || warn "can't find cr/lf"; + return $result; +} + =head1 Connection Handling =head2 quit @@ -119,12 +126,6 @@ sub get { =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 { @@ -134,7 +135,7 @@ sub incr { } else { print $sock "INCR $key\r\n"; } - sock_result(); + _sock_result(); } =head2 decr @@ -151,7 +152,7 @@ sub decr { } else { print $sock "DECR $key\r\n"; } - sock_result(); + _sock_result(); } =head2 exists @@ -163,7 +164,7 @@ sub decr { sub exists { my ( $self, $key ) = @_; print $sock "EXISTS $key\r\n"; - sock_result(); + _sock_result(); } =head2 del @@ -175,7 +176,19 @@ sub exists { sub del { my ( $self, $key ) = @_; print $sock "DEL $key\r\n"; - sock_result(); + _sock_result(); +} + +=head2 type + + $r->type( 'key' ); # = string + +=cut + +sub type { + my ( $self, $key ) = @_; + print $sock "type $key\r\n"; + _sock_result(); } =head1 AUTHOR diff --git a/t/01-Redis.t b/t/01-Redis.t index 3e53cf3..ff41882 100755 --- a/t/01-Redis.t +++ b/t/01-Redis.t @@ -3,7 +3,7 @@ use warnings; use strict; -use Test::More tests => 43; +use Test::More tests => 44; use lib 'lib'; @@ -56,4 +56,6 @@ foreach ( 1 .. 3 ) { ok( $o->del('key-next' ), 'del' ); +cmp_ok( $o->type('foo'), 'eq', 'string', 'type' ); + ok( $o->quit, 'quit' ); -- 2.20.1