51 |
$self; |
$self; |
52 |
} |
} |
53 |
|
|
54 |
|
sub _sock_result { |
55 |
|
my $result = <$sock>; |
56 |
|
warn "# result: ",dump( $result ); |
57 |
|
$result =~ s{\r\n$}{} || warn "can't find cr/lf"; |
58 |
|
return $result; |
59 |
|
} |
60 |
|
|
61 |
=head1 Connection Handling |
=head1 Connection Handling |
62 |
|
|
63 |
=head2 quit |
=head2 quit |
126 |
|
|
127 |
=cut |
=cut |
128 |
|
|
|
sub sock_result { |
|
|
my $result = <$sock>; |
|
|
warn "# result: ",dump( $result ); |
|
|
$result =~ s{\r\n$}{} || warn "can't find cr/lf"; |
|
|
return $result; |
|
|
} |
|
129 |
|
|
130 |
|
|
131 |
sub incr { |
sub incr { |
135 |
} else { |
} else { |
136 |
print $sock "INCR $key\r\n"; |
print $sock "INCR $key\r\n"; |
137 |
} |
} |
138 |
sock_result(); |
_sock_result(); |
139 |
} |
} |
140 |
|
|
141 |
=head2 decr |
=head2 decr |
152 |
} else { |
} else { |
153 |
print $sock "DECR $key\r\n"; |
print $sock "DECR $key\r\n"; |
154 |
} |
} |
155 |
sock_result(); |
_sock_result(); |
156 |
} |
} |
157 |
|
|
158 |
=head2 exists |
=head2 exists |
164 |
sub exists { |
sub exists { |
165 |
my ( $self, $key ) = @_; |
my ( $self, $key ) = @_; |
166 |
print $sock "EXISTS $key\r\n"; |
print $sock "EXISTS $key\r\n"; |
167 |
sock_result(); |
_sock_result(); |
168 |
} |
} |
169 |
|
|
170 |
=head2 del |
=head2 del |
176 |
sub del { |
sub del { |
177 |
my ( $self, $key ) = @_; |
my ( $self, $key ) = @_; |
178 |
print $sock "DEL $key\r\n"; |
print $sock "DEL $key\r\n"; |
179 |
sock_result(); |
_sock_result(); |
180 |
|
} |
181 |
|
|
182 |
|
=head2 type |
183 |
|
|
184 |
|
$r->type( 'key' ); # = string |
185 |
|
|
186 |
|
=cut |
187 |
|
|
188 |
|
sub type { |
189 |
|
my ( $self, $key ) = @_; |
190 |
|
print $sock "type $key\r\n"; |
191 |
|
_sock_result(); |
192 |
} |
} |
193 |
|
|
194 |
=head1 AUTHOR |
=head1 AUTHOR |