Test::...sServer(3pm)
π Test::RedisServer β the perl manpage but make it bestie π
okay so this is Test::RedisServer(3pm) from the User Contributed Perl Documentation, and it's literally a redis-server runner for tests. that's the whole NAME section. no cap.
β¨ SYNOPSIS β¨
the vibe, verbatim:
use Redis;
use Test::RedisServer;
use Test::More;
my $redis_server;
eval {
$redis_server = Test::RedisServer->new;
} or plan skip_all => 'redis-server is required for this test';
my $redis = Redis->new( $redis_server->connect_info );
is $redis->ping, 'PONG', 'ping pong ok';
done_testing;
like, if redis-server isn't there you just skip the whole test suite and move on with your life. self-care π
π¦ DESCRIPTION π¦
bestie. there is genuinely nothing here. the DESCRIPTION section is empty. it's giving minimalist. it's giving "the methods below speak for themselves." periodt.
π METHODS π
πΈ new(%options)
my $redis_server = Test::RedisServer->new(%options);
creates a new redis-server instance, and β plot twist β it starts it by default. if you don't want that auto-magic, use the auto_start option, which is right down there π
available options are:
auto_start => 0 | 1β default is1. it automatically starts the redis-server instance (that's the default behavior, bestie). you can turn this off withauto_start => 0, and then start the instance yourself, manually, with thestartorexecmethods below. main character energy: you decide.conf => 'HashRef'β this is your redis.conf key value pair situation. you can use any key-value pair(s) that redis-server supports. go wild, it's your config.
if you want to use this redis.conf:
port 9999
databases 16
save 900 1
your conf parameter will be:
Test::RedisServer->new( conf => {
port => 9999,
databases => 16,
save => '900 1',
});
timeout => 'Int'β timeout seconds for detecting if redis-server is awake or not. default is3. it's basically the "are you up bestie??" check.tmpdir => 'String'β temporal directory, where the redis config will be stored. by default it's created for you π«Ά but if you startTest::RedisServerviaexec(e.g. withTest::TCP), you should provide it so it gets automatically deleted. your temp files deserve a clean exit too.
π₯ start
start the redis-server instance manually. you're in charge now π
π exec
just exec to redis-server instance. this method is useful to use this module with Test::TCP, Proclet or etc. like, it's the plug-and-play option.
use File::Temp;
use Test::TCP;
my $tmp_dir = File::Temp->newdir( CLEANUP => 1 );
test_tcp(
client => sub {
my ($port, $server_pid) = @_;
...
},
server => sub {
my ($port) = @_;
my $redis = Test::RedisServer->new(
auto_start => 0,
conf => { port => $port },
tmpdir => $tmp_dir,
);
$redis->exec;
},
);
π stop
stop the redis-server instance. it's the "okay bye bestie, love you, text me" of methods.
this method is automatically called from the object destructor, DESTROY. so it's already handled, you don't have to think about it, iconic behavior honestly.
π connect_info
return connection info for the client library to connect this redis-server instance.
this parameter is designed to pass directly to the Redis module. chef's kiss, no conversion needed.
my $redis_server = Test::RedisServer->new;
my $redis = Redis->new( $redis_server->connect_info );
π pid
return redis-server instance's process id, or undef when redis-server is not running. so if you get undef, that server is not okay and you should check on it π
β wait_exit
block until redis instance exited. it just sits there. patiently. waiting. like a loyal bestie outside the fitting room.
π SEE ALSO π
Test::mysqldfor mysqld.Test::Memcachedfor Memcached.
this module steals lots of stuff from above modules. respectfully. it's inspired, not copied, we don't gatekeep β¨
Test::Mock::Redis, another approach for testing redis application. an alternative vibe, if you will.
π§ INTERNAL METHODS π§
BUILD
DEMOLISH
these are internal. hands off, bestie. they're doing important behind-the-scenes work and they don't need your commentary π
π AUTHOR π
Daisuke Murase <typester@cpan.org>
π COPYRIGHT AND LICENSE π
Copyright (c) 2012 KAYAC Inc. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
ngl the LICENSE file is real and you should actually read it. legal girlies stay winning.
okay that's the whole page!! this was documented with perl v5.40.1, dated 2026-01-31, and it's the Test::RedisServer(3pm) manpage β mwah, slay, go write some tests π
πΈπ¦
π¦ where this page comes from
- ubuntu resolute: libtest-redisserver-perl 0.24-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest-redisserver-perl 0.24-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms