use Data::Dump qw(dump);
sub redis {
- AnyEvent::Redis->new( host => $ENV{REDIS_HOST}, port => $ENV{REDIS_PORT}, on_error => sub { confess @_ } );
+ my $redis = AnyEvent::Redis->new( host => $ENV{REDIS_HOST}, port => $ENV{REDIS_PORT}, on_error => sub { confess @_ } );
+ $redis->ping;
+ return $redis;
}
sub publish {
- my ( $channel, $body ) = @_;
+ my ( $self, $channel, $body ) = @_;
$channel = join(' ', @$channel) if ref $channel eq 'ARRAY';
my $pub = redis;
$pub->publish( $channel, $body );