/[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 2 by dpavlin, Sat Mar 21 21:25:52 2009 UTC revision 4 by dpavlin, Sat Mar 21 21:53:15 2009 UTC
# Line 66  sub quit { Line 66  sub quit {
66    
67  =head2 ping  =head2 ping
68    
69          $r->ping || die "no server?";    $r->ping || die "no server?";
70    
71  =cut  =cut
72    
# Line 76  sub ping { Line 76  sub ping {
76          die "ping failed, got ", dump($pong) unless $pong eq "+PONG\r\n";          die "ping failed, got ", dump($pong) unless $pong eq "+PONG\r\n";
77  }  }
78    
79    =head1 Commands operating on string values
80    
81    =head2 set
82    
83      $r->set( foo => 'bar' );
84    
85    =cut
86    
87    sub set {
88            my ( $self, $k, $v ) = @_;
89            print $sock "SET $k " . length($v) . "\r\n$v\r\n";
90            my $ok = <$sock>;
91            die dump($ok) unless $ok eq "+OK\r\n";
92    }
93    
94    =head2 get
95    
96      my $value = $r->get( 'foo' );
97    
98    =cut
99    
100    sub get {
101            my ( $self, $k ) = @_;
102            print $sock "GET $k\r\n";
103            my $len = <$sock>;
104    #       warn "# len: ",dump($len);
105            return undef if $len eq "nil\r\n";
106            my $v;
107            read($sock, $v, $len) || die $!;
108    #       warn "# v: ",dump($v);
109            my $crlf;
110            read($sock, $crlf, 2); # skip cr/lf
111            return $v;
112    }
113    
114    
115    
116  =head1 AUTHOR  =head1 AUTHOR
117    
118  Dobrica Pavlinusic, C<< <dpavlin at rot13.org> >>  Dobrica Pavlinusic, C<< <dpavlin at rot13.org> >>

Legend:
Removed from v.2  
changed lines
  Added in v.4

  ViewVC Help
Powered by ViewVC 1.1.26