NAME

Mojo::Redis2::Client - Mojo::Redis2 CLIENT commands

DESCRIPTION

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)

SYNOPSIS

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);
  },
);

METHODS

kill

$res = $self->kill(@args);
$self = $self->kill(@args => sub { my ($redis, $err, $res) = @_; });

Will run CLIENT KILL ... command. Example:

$self->kill("1.2.3.4:12345");
$self->kill(ID => "foo-connection-123");
$self->kill(TYPE => "normal", SKIPME => "yes");

list

$list = $self->list;
$self = $self->list(sub { my ($redis, $err, $list) = @_; });

Runs CLIENT LIST and retrieves the client data in a structured format:

{
  "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.

name

# 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 AND LICENSE

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.

AUTHOR

Jan Henning Thorsen - jhthorsen@cpan.org