NAME

Mojo::Redis::Connection - Low level connection class for talking to Redis

SYNOPSIS

use Mojo::Redis::Connection;

my $conn = Mojo::Redis::Connection->new(
             ioloop   => Mojo::IOLoop->singleton,
             protocol => Protocol::Redis::XS->new(api => 1),
             url      => Mojo::URL->new("redis://localhost"),
           );

$conn->write_p("GET some_key")->then(sub { print "some_key=$_[0]" })->wait;

DESCRIPTION

Mojo::Redis::Connection is a low level driver for writing and reading data from a Redis server.

You probably want to use Mojo::Redis instead of this class.

ATTRIBUTES

ioloop

$loop = $self->ioloop;
$self = $self->ioloop(Mojo::IOLoop->new);

Holds an instance of Mojo::IOLoop.

protocol

$protocol = $self->protocol;
$self = $self->protocol(Protocol::Redis::XS->new(api => 1));

Holds a protocol object, such as Protocol::Redis that is used to generate and parse Redis messages.

url

$url = $self->url;
$self = $self->url(Protocol::Redis::XS->new(api => 1));

METHODS

disconnect

$self = $self->disconnect;

Used to disconnect from the Redis server.

is_connected

$bool = $self->is_connected;

True if a connection to the Redis server is established.

write_p

$promise = $self->write_p($command => @args);

Will write a command to the Redis server and establish a connection if not already connected and returns a Mojo::Promise. The arguments will be passed on to "write_q".

write_q

$self = $self->write_q(@command => @args, Mojo::Promise->new);
$self = $self->write_q(@command => @args, undef);

Will enqueue a Redis command and either resolve/reject the Mojo::Promise or emit a "error" or "message" event when the Redis server responds.

This method is EXPERIMENTAL and currently meant for internal use.

SEE ALSO

Mojo::Redis