NAME

Mojo::Redis2::Backend - Mojo::Redis2 server commands

DESCRIPTION

Mojo::Redis2::Backend allow running server 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->backend->config("dbfilename");

Mojo::IOLoop->delay(
  sub {
    my ($delay) = @_;
    $redis->backend->config(dbfilename => $delay->begin);
  },
  sub {
    my ($delay, $err, $dbfilename) = @_;
    $self->render(text => $err || $dbfilename);
  },
);

METHODS

bgrewriteaof

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

See http://redis.io/commands/bgrewriteaof for details.

bgsave

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

See http://redis.io/commands/bgsave for details.

config

# CONFIG GET $key
$res = $self->config($key);
$self = $self->config($key => sub { my ($redis, $err, $res) = @_; });

# CONFIG SET $key $value
$self = $self->config($key => $value => sub { my ($redis, $err, $res) = @_; });
$res = $self->config($key => $value);

Used to retrieve or set config parameters. $res will differ dependent on input:

| $self->config(dbfilename => "foo.rdb") | $res = "OK"                 |
| $self->config("dbfilename")            | "foo.rdb"                   |
| $self->config("dbfile*")               | { dbfilename => "foo.rdb" } |

dbsize

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

See http://redis.io/commands/dbsize for details.

flushall

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

See http://redis.io/commands/flushall for details.

flushdb

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

See http://redis.io/commands/flushdb for details.

info

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

Used to retrieve information about a given $section. Example $res when $section is "clients":

{
  connected_clients => "3",
  client_longest_output_list => "30",
  client_biggest_input_buf => "100",
  blocked_clients => "0",
}

lastsave

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

See http://redis.io/commands/lastsave for details.

resetstat

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

Used to reset the statistics reported by Redis using the "info" method.

rewrite

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

Used to rewrite the config file.

save

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

See http://redis.io/commands/save for details.

time

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

See http://redis.io/commands/time for details. $res holds the same format as "gettimeofday" in Time::Hires in an array-ref:

[ 1409045324, 311294 ];

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