/[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 5 by dpavlin, Sat Mar 21 22:20:51 2009 UTC revision 9 by dpavlin, Sat Mar 21 22:54:10 2009 UTC
# Line 112  sub get { Line 112  sub get {
112          return $v;          return $v;
113  }  }
114    
115    =head2 incr
116    
117      $r->incr('counter');
118      $r->incr('tripplets', 3);
119    
120    =cut
121    
122    sub incr {
123            my ( $self, $key, $value ) = @_;
124            if ( defined $value ) {
125                    print $sock "INCRBY $key $value\r\n";
126            } else {
127                    print $sock "INCR $key\r\n";
128            }
129            my $count = <$sock>;
130            warn "# $key = $count";
131            return $count;
132    }
133    
134    =head2 decr
135    
136      $r->decr('counter');
137      $r->decr('tripplets', 3);
138    
139    =cut
140    
141    sub decr {
142            my ( $self, $key, $value ) = @_;
143            if ( defined $value ) {
144                    print $sock "DECRBY $key $value\r\n";
145            } else {
146                    print $sock "DECR $key\r\n";
147            }
148            my $count = <$sock>;
149            warn "# $key = $count";
150            return $count;
151    }
152    
153    =head2 exists
154    
155      $r->exists( 'key' ) && print "got key!";
156    
157    =cut
158    
159    sub exists {
160            my ( $self, $key ) = @_;
161            print $sock "EXISTS $key\r\n";
162            my $found = <$sock>;
163            $found =~ s{\r\n$}{};
164            warn "# exists $key = $found";
165            return $found;
166    }
167    
168  =head1 AUTHOR  =head1 AUTHOR
169    

Legend:
Removed from v.5  
changed lines
  Added in v.9

  ViewVC Help
Powered by ViewVC 1.1.26