Mojo::Redis2::Client - Mojo::Redis2 CLIENT commands
Mojo::Redis2::Client allow running CLIENT commands in a structured manner.
NOTE: All the callbacks get the $redis object and not $self. (This might change in the future)
$redis
$self
use Mojo::Redis2; my $redis = Mojo::Redis2->new; $res = $redis->client->kill("127.0.0.1:12345"); Mojo::IOLoop->delay( sub { my ($delay) = @_; $redis->client->name($delay->begin); }, sub { my ($delay, $err, $name) = @_; $self->render(text => $err || $name); }, );
$res = $self->kill(@args); $self = $self->kill(@args => sub { my ($redis, $err, $res) = @_; });
Will run CLIENT KILL ... command. Example:
CLIENT KILL ...
$self->kill("1.2.3.4:12345"); $self->kill(ID => "foo-connection-123"); $self->kill(TYPE => "normal", SKIPME => "yes");
$list = $self->list; $self = $self->list(sub { my ($redis, $err, $list) = @_; });
Runs CLIENT LIST and retrieves the client data in a structured format:
CLIENT LIST
{ "1.2.3.4:12345" => { addr => "1.2.3.4:12345", db => "3", flags => "N", idle => "107", ... }, ... }
The data will differ by Redis version. Look at http://redis.io/commands/client-list for details.
NOTE: The values might be forced into real integers in future versions, but they are strings now.
# CLIENT GETNAME $name = $self->name; $self = $self->name(sub { my ($redis, $err, $name) = @_; }); # CLIENT SETNAME $name $res = $self->name($str); $self = $self->name($str => sub { my ($redis, $err, $res) = @_; });
Used to set or get the connection name. Note: This will only set the connection name for the "basic" operations (not SUBSCRIBE, BLPOP and friends). Also, setting the connection in blocking mode, will not change the non-blocking and visa versa.
TODO: Support setting name for SUBSCRIBE, BLPOP, ... connections.
Copyright (C) 2014, Jan Henning Thorsen
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
Jan Henning Thorsen - jhthorsen@cpan.org
jhthorsen@cpan.org
To install Mojo::Redis2, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::Redis2
CPAN shell
perl -MCPAN -e shell install Mojo::Redis2
For more information on module installation, please visit the detailed CPAN module installation guide.