Skip to content

Instantly share code, notes, and snippets.

@esobchenko
Forked from sinkovsky/gist:880986
Created March 22, 2011 09:41
Show Gist options
  • Save esobchenko/880991 to your computer and use it in GitHub Desktop.
Save esobchenko/880991 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use MojoX::Redis;
my $redis1 = MojoX::Redis->new();
$redis1
->sadd ( "set1" => "foo" )
->set ( "foo" => "foo desc" )
->sadd ( "set1" => "bar" )
->set ( "bar" => "bar desc" )
->sadd ( "set2" => "foo2" )
->set ( "foo2" => "foo2 desc" )
->sadd ( "set2" => "bar2" )
->set ( "bar2" => "bar2 desc" )
->quit( sub { shift->stop } )->start;
my $redis2 = MojoX::Redis->new();
$redis2->smembers ( "set1",
sub {
my ( $redis, $res ) = @_;
my $members = @$res;
foreach my $e ( @$res ) {
$redis->get( $e => sub { printf "%s %s\n", $e, $_[1]->[0]; $redis->stop unless --$members;} );
}
}
)->smembers ( "set2",
sub {
my ( $redis, $res ) = @_;
my $members = @$res;
foreach my $e ( @$res ) {
$redis->get( $e => sub { printf "%s %s\n", $e, $_[1]->[0]; $redis->stop unless --$members;} );
}
}
)->start;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment