The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test::Memcached - Memcached Runner For Tests

SYNOPSIS

    use Test::Memcached;

    my $memd = Test::MEmcached->new(
        options => {
            user => 'memcached-user',
        }
    );

    $memd->start;

    my $port = $memd->option( 'tcp_port' );

    my $client = Cache::Memcached->new({
        servers => [ "127.0.0.1:$port" ]
    });
    $client->get(...);

    $memd->stop; 

DESCRIPTION

Test::Memcached automatically sets up a memcached instance, and destroys it when the perl script exists.

METHODS

new

Creates a new instance. you can set the location of memcached by explicitly setting it, or it will attempt to find it.

You can speficy a set of options to pass to memcached. Below table shows the values that you can use, and the option name that will be mapped to:

    tcp_port                  : 'p'
    udp_port                  : 'U'
    unix_socket               : 's'
    unix_socket_mask          : 'a'
    bind                      : 'l'
    max_core_limit            : 'r'
    user                      : 'u'
    max_memory                : 'm'
    error_on_exhausted_memory : 'M'
    max_connections           : 'c'
    lock_down                 : 'k'
    verbose                   : 'v'
    pidfile                   : 'P'
    chunk_size_factor         : 'f'
    minimum_space             : 'n'
    use_large_memory_pages    : 'L'
    delimiter                 : 'D'
    threads                   : 't'
    requests_per_event        : 'R'
    disable_cas               : 'C'
    backlog_limit             : 'b'
    bind_protocol             : 'B'
    item_size                 : 'I'

option

Gets the current value of the named option

    my $port = $memd->option('tcp_port');

start

If no unix_socket, udp_port is set, automatically looks for an empty port to listen on, and starts memcached.

stop

stops memcached. by sending TERM signal

DESTROY

When the object goes out of scope, stop gets called.

AUTHORS

Kazuho Oku wrote Test::mysqld, which I shamelessly stole from.

Tokuhiro Matsuno wrote Test::TCP, which I also shamelessly stole from

Daisuke Maki <daisuke@endeworks.jp>

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html