Skip to content

Instantly share code, notes, and snippets.

@mythosil
Created July 20, 2011 17:27
Show Gist options
  • Save mythosil/1095419 to your computer and use it in GitHub Desktop.
Save mythosil/1095419 to your computer and use it in GitHub Desktop.
AnyEvent::Redis subscribe
use strict;
use warnings;
use AnyEvent::Redis;
my $redis = AnyEvent::Redis->new(
host => '127.0.0.1',
port => 6379,
encoding => 'utf8',
on_error => sub { warn @_ },
);
my $cv = $redis->subscribe("subscribe_test", sub {
my ($message, $channel) = @_;
print "$channel : $message\n";
});
$cv->recv;
__END__
How to test this script
$ redis-cli publish "subscribe_test" "message"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment