/[Redis.pre-github]/lib/Redis.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/Redis.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 11 by dpavlin, Sat Mar 21 23:09:48 2009 UTC revision 12 by dpavlin, Sat Mar 21 23:23:37 2009 UTC
# Line 58  sub _sock_result { Line 58  sub _sock_result {
58          return $result;          return $result;
59  }  }
60    
61    sub _sock_result_bulk {
62            my $len = <$sock>;
63            warn "# len: ",dump($len);
64            return undef if $len eq "nil\r\n";
65            my $v;
66            read($sock, $v, $len) || die $!;
67            warn "# v: ",dump($v);
68            my $crlf;
69            read($sock, $crlf, 2); # skip cr/lf
70            return $v;
71    }
72    
73  =head1 Connection Handling  =head1 Connection Handling
74    
75  =head2 quit  =head2 quit
# Line 108  sub set { Line 120  sub set {
120  sub get {  sub get {
121          my ( $self, $k ) = @_;          my ( $self, $k ) = @_;
122          print $sock "GET $k\r\n";          print $sock "GET $k\r\n";
123          my $len = <$sock>;          _sock_result_bulk();
 #       warn "# len: ",dump($len);  
         return undef if $len eq "nil\r\n";  
         my $v;  
         read($sock, $v, $len) || die $!;  
 #       warn "# v: ",dump($v);  
         my $crlf;  
         read($sock, $crlf, 2); # skip cr/lf  
         return $v;  
124  }  }
125    
126  =head2 incr  =head2 incr
# Line 187  sub del { Line 191  sub del {
191    
192  sub type {  sub type {
193          my ( $self, $key ) = @_;          my ( $self, $key ) = @_;
194          print $sock "type $key\r\n";          print $sock "TYPE $key\r\n";
195          _sock_result();          _sock_result();
196  }  }
197    
198    =head1 Commands operating on the key space
199    
200    =head2 keys
201    
202      my @keys = $r->keys( '*glob_pattern*' );
203    
204    =cut
205    
206    sub keys {
207            my ( $self, $glob ) = @_;
208            print $sock "KEYS $glob\r\n";
209            return split(/\s/, _sock_result_bulk());
210    }
211    
212  =head1 AUTHOR  =head1 AUTHOR
213    
214  Dobrica Pavlinusic, C<< <dpavlin at rot13.org> >>  Dobrica Pavlinusic, C<< <dpavlin at rot13.org> >>

Legend:
Removed from v.11  
changed lines
  Added in v.12

  ViewVC Help
Powered by ViewVC 1.1.26