Created
July 20, 2011 17:27
-
-
Save mythosil/1095419 to your computer and use it in GitHub Desktop.
AnyEvent::Redis subscribe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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