/[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 7 by dpavlin, Sat Mar 21 22:38:56 2009 UTC revision 10 by dpavlin, Sat Mar 21 23:05:02 2009 UTC
# Line 119  sub get { Line 119  sub get {
119    
120  =cut  =cut
121    
122    sub sock_result {
123            my $result = <$sock>;
124            warn "# result: ",dump( $result );
125            $result =~ s{\r\n$}{} || warn "can't find cr/lf";
126            return $result;
127    }
128            
129    
130  sub incr {  sub incr {
131          my ( $self, $key, $value ) = @_;          my ( $self, $key, $value ) = @_;
132          if ( defined $value ) {          if ( defined $value ) {
# Line 126  sub incr { Line 134  sub incr {
134          } else {          } else {
135                  print $sock "INCR $key\r\n";                  print $sock "INCR $key\r\n";
136          }          }
137          my $count = <$sock>;          sock_result();
138          warn "# $key = $count";  }
139          return $count;  
140    =head2 decr
141    
142      $r->decr('counter');
143      $r->decr('tripplets', 3);
144    
145    =cut
146    
147    sub decr {
148            my ( $self, $key, $value ) = @_;
149            if ( defined $value ) {
150                    print $sock "DECRBY $key $value\r\n";
151            } else {
152                    print $sock "DECR $key\r\n";
153            }
154            sock_result();
155    }
156    
157    =head2 exists
158    
159      $r->exists( 'key' ) && print "got key!";
160    
161    =cut
162    
163    sub exists {
164            my ( $self, $key ) = @_;
165            print $sock "EXISTS $key\r\n";
166            sock_result();
167    }
168    
169    =head2 del
170    
171      $r->del( 'key' ) || warn "key doesn't exist";
172    
173    =cut
174    
175    sub del {
176            my ( $self, $key ) = @_;
177            print $sock "DEL $key\r\n";
178            sock_result();
179  }  }
180    
181  =head1 AUTHOR  =head1 AUTHOR

Legend:
Removed from v.7  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26