return $count;
}
+=head2 exists
+
+ $r->exists( 'key' ) && print "got key!";
+
+=cut
+
+sub exists {
+ my ( $self, $key ) = @_;
+ print $sock "EXISTS $key\r\n";
+ my $found = <$sock>;
+ $found =~ s{\r\n$}{};
+ warn "# exists $key = $found";
+ return $found;
+}
+
=head1 AUTHOR
Dobrica Pavlinusic, C<< <dpavlin at rot13.org> >>
use warnings;
use strict;
-use Test::More tests => 37;
+use Test::More tests => 42;
use lib 'lib';
cmp_ok( $o->get( 'foo' ), 'eq', 'baz', 'get foo = baz' );
+ok( ! $o->exists( 'non-existant' ), 'exists non-existant' );
ok( ! $o->get( 'non-existant' ), 'get non-existant' );
ok( $o->set('key-next' => 0), 'key-next = 0' );
foreach ( 0 .. $key_next ) {
ok( $o->set( "key-$_" => $_ ), "set key-$_" );
+ ok( $o->exists( "key-$_" ), "exists key-$_" );
cmp_ok( $o->get( "key-$_" ), 'eq', $_, "get key-$_" );
cmp_ok( $o->incr( 'key-next' ), '==', $_ + 1, 'incr' );
cmp_ok( $o->decr( 'key-left' ), '==', $key_next - $_ - 1, 'decr' );