randomkey
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 21 Mar 2009 23:26:46 +0000 (23:26 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 21 Mar 2009 23:26:46 +0000 (23:26 +0000)
git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/Redis@13 447b33ff-793d-4489-8442-9bea7d161be5

lib/Redis.pm
t/01-Redis.t

index f0b21a2..6c88fd5 100644 (file)
@@ -209,6 +209,18 @@ sub keys {
        return split(/\s/, _sock_result_bulk());
 }
 
+=head2 randomkey
+
+  my $key = $r->randomkey;
+
+=cut
+
+sub randomkey {
+       my ( $self, $glob ) = @_;
+       print $sock "RANDOMKEY\r\n";
+       _sock_result();
+}
+
 =head1 AUTHOR
 
 Dobrica Pavlinusic, C<< <dpavlin at rot13.org> >>
index 7dad9f7..a27ae37 100755 (executable)
@@ -3,7 +3,7 @@
 use warnings;
 use strict;
 
-use Test::More tests => 48;
+use Test::More tests => 49;
 
 use lib 'lib';
 
@@ -66,4 +66,7 @@ cmp_ok( $o->type('foo'), 'eq', 'string', 'type' );
 cmp_ok( $o->keys('key-*'), '==', $key_next + 1, 'key-*' );
 is_deeply( [ $o->keys('key-*') ], [ @keys ], 'keys' );
 
+ok( my $key = $o->randomkey, 'randomkey' );
+diag "key: $key";
+
 ok( $o->quit, 'quit' );