NAME

Mojo::Redis::Subscription - Result of Mojo::Redis->subscribe()

SYNOPSIS

use Mojo::Redis;
$r = Mojo::Redis->new;
$s = $r->subscribe('foo', sub { ... });

use Mojo::Redis::Subscription;
my $s = Mojo::Redis::Subscription->new;
$s->on(message => sub { ... });

EVENTS

message

$self->on(message => sub { my($self, $channel, $message) = @_; ... });

This event receive the messages sent over the channel.

data

$self->on(data => sub { my($self, $data) = @_; ... });

This event receive all data sent over the channel. Example:

0: ['subscribe', 'first_channel_name', 1];
1: ['message', 'first_channel_name','yay!']

ATTRIBUTES

channels

Holds an array ref of channel names which this object subscribe to.

METHODS

connect

Used to connect to the redis server and start subscribing to the "channels". This is called automatically from "subscribe" in Mojo::Redis.

disconnect

Will remove the connection to the redis server. This also happen when the object goes out of scope.

AUTHOR

Jan Henning Thorsen - jhthorsen@cpan.org