X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=lib%2FMQR%2FRedis.pm;fp=lib%2FMQR%2FRedis.pm;h=119cb4643424d5fbb3775c0bb62bf68c5ec2c063;hb=e55607ec09d89bdf63a07289dbd09ab7306ad3c6;hp=0000000000000000000000000000000000000000;hpb=f23666dbe2b600a36111ec10b2bdfdb813be93db;p=MQR.git diff --git a/lib/MQR/Redis.pm b/lib/MQR/Redis.pm new file mode 100644 index 0000000..119cb46 --- /dev/null +++ b/lib/MQR/Redis.pm @@ -0,0 +1,19 @@ +package MQR::Redis; + +use AnyEvent::Redis; +use Carp qw(confess); +use Data::Dump qw(dump); + +sub redis { + AnyEvent::Redis->new( host => $ENV{REDIS_HOST}, port => $ENV{REDIS_PORT}, on_error => sub { confess @_ } ); +} + +sub publish { + my ( $channel, $body ) = @_; + $channel = join(' ', @$channel) if ref $channel eq 'ARRAY'; + my $pub = redis; + $pub->publish( $channel, $body ); + warn ">>>> ",dump($channel, $body); +} + +1;