NAME

Mojo::Redis2::Server - Start a test server

DESCRIPTION

Mojo::Redis2::Server is a class for starting an instances of the Redis server. The server is stopped when the instance of this class goes out of scope.

Note: This module is only meant for unit testing. It is not good enough for keeping a production server up and running at this point.

SYNOPSIS

use Mojo::Redis2::Server;

{
  my $server = Mojo::Redis2::Server->new;
  $server->start;
  # server runs here
}

# server is stopped here

ATTRIBUTES

config

$hash_ref = $self->config;

Contains the full configuration of the Redis server.

configure_environment

$bool = $self->configure_environment;
$self = $self->configure_environment($bool);

"start" will set the MOJO_REDIS_URL environment variable unless this attribute is set to false.

pid

$int = $self->pid;

The pid of the Redis server.

url

$str = $self->url;

Contains a value suitable for "url" in Mojo::Redis2.

METHODS

singleton

$self = $class->singleton;

Returns the singleton which is used when "start" and "stop" is called as class methods, instead of instance methods.

start

$self = $self->start(%config);

This method will try to start an instance of the Redis server or die() trying. The input config is a key/value structure with valid Redis config file settings.

stop

$self = $self->stop;

Will stop a running Redis server or die trying.

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