Test::Memcached - Memcached Runner For Tests
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;
Test::Memcached automatically sets up a memcached instance, and destroys it when the perl script exists.
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'
Gets the current value of the named option
my $port = $memd->option('tcp_port');
If no unix_socket, udp_port is set, automatically looks for an empty port to listen on, and starts memcached.
stops memcached. by sending TERM signal
When the object goes out of scope, stop gets called.
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>
<daisuke@endeworks.jp>
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
To install Test::Memcached, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Memcached
CPAN shell
perl -MCPAN -e shell install Test::Memcached
For more information on module installation, please visit the detailed CPAN module installation guide.