Mojo::Redis::Subscription - Result of Mojo::Redis->subscribe()
You can create a Mojo::Redis::Subscription object in two ways:
Either from Mojo::Redis:
use Mojo::Redis; $r = Mojo::Redis->new; $s = $r->subscribe('foo'); # does also ->connect() print @{ $s->channels } # print "foo";
...or from Mojo::Redis::Subscription:
use Mojo::Redis::Subscription; my $s = Mojo::Redis::Subscription->new; $s->channels(['foo']); $s->connect;
Either way you need to subscribe to an event:
$s->on(message => sub { my($s, $message, $channel) = @_; }); Mojo::IOLoop->start;
$self->on(message => sub { my($self, $message, $channel) = @_; ... });
This event receive the messages sent over the channel.
$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!']
Holds an array ref of channel names which this object subscribe to.
Describes the sort of subscription this object is using: subscribe or psubscribe.
Used to connect to the redis server and start subscribing to the "channels". This is called automatically from "subscribe" in Mojo::Redis.
Will remove the connection to the redis server. This also happen when the object goes out of scope.
Jan Henning Thorsen - jhthorsen@cpan.org
jhthorsen@cpan.org
To install Mojo::Redis, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::Redis
CPAN shell
perl -MCPAN -e shell install Mojo::Redis
For more information on module installation, please visit the detailed CPAN module installation guide.