sinterstore
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 22 Mar 2009 17:37:46 +0000 (17:37 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 22 Mar 2009 17:37:46 +0000 (17:37 +0000)
git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/Redis@34 447b33ff-793d-4489-8442-9bea7d161be5

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

index 10594cd..ed5e2ad 100644 (file)
@@ -460,6 +460,17 @@ sub sinter {
        $self->_sock_result_bulk_list( 'SINTER', @_ );
 }
 
        $self->_sock_result_bulk_list( 'SINTER', @_ );
 }
 
+=head2 sinterstore
+
+  my $ok = $r->sinterstore( $dstkey, $key1, $key2, ... );
+
+=cut
+
+sub sinterstore {
+       my $self = shift;
+       $self->_sock_send_ok( 'SINTERSTORE', @_ );
+}
+
 =head1 AUTHOR
 
 Dobrica Pavlinusic, C<< <dpavlin at rot13.org> >>
 =head1 AUTHOR
 
 Dobrica Pavlinusic, C<< <dpavlin at rot13.org> >>
index 3fb3565..77fd499 100755 (executable)
@@ -3,7 +3,7 @@
 use warnings;
 use strict;
 
 use warnings;
 use strict;
 
-use Test::More tests => 84;
+use Test::More tests => 86;
 
 use lib 'lib';
 
 
 use lib 'lib';
 
@@ -134,6 +134,12 @@ cmp_ok( $o->scard( $set ), '==', 0, 'scard' );
 $o->sadd( 'test-set1', $_ ) foreach ( 'foo', 'bar', 'baz' );
 $o->sadd( 'test-set2', $_ ) foreach ( 'foo', 'baz', 'xxx' );
 
 $o->sadd( 'test-set1', $_ ) foreach ( 'foo', 'bar', 'baz' );
 $o->sadd( 'test-set2', $_ ) foreach ( 'foo', 'baz', 'xxx' );
 
-is_deeply( [ $o->sinter( 'test-set1', 'test-set2' ) ], [ 'baz', 'foo' ], 'siter' );
+my $inter = [ 'baz', 'foo' ];
+
+is_deeply( [ $o->sinter( 'test-set1', 'test-set2' ) ], $inter, 'siter' );
+
+ok( $o->sinterstore( 'test-set-inter', 'test-set1', 'test-set2' ), 'sinterstore' );
+
+cmp_ok( $o->scard( 'test-set-inter' ), '==', $#$inter + 1, 'cardinality of intersection' );
 
 ok( $o->quit, 'quit' );
 
 ok( $o->quit, 'quit' );